[C#]几种字符串反转方法效率比较
2006-10-31 07:08
651 查看
下面是实现字符串反转的四种方法:
static string Reverse1(string original)
static string Revease21(string original)
static string Revease22(string original)
static string Revease3(string original)
static void Main(string[] args)
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Reverse(Array array)
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Reverse(Array array, int index, int length)
public StringBuilder Append(string value)
private bool NeedsAllocation(string currentString, int requiredLength)
internal unsafe void AppendInPlace(string value, int currentLength)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int num1 = value.Length;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int num2 = currentLength + num1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fixed (char* chRef1 = &this.m_firstChar)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fixed (char* chRef2 = &value.m_firstChar)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string.wstrcpy(chRef1 + currentLength, chRef2, num1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
chRef1[num2] = '
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1357692
static string Reverse1(string original)
static string Revease21(string original)
static string Revease22(string original)
static string Revease3(string original)
static void Main(string[] args)
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Reverse(Array array)
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Reverse(Array array, int index, int length)
public StringBuilder Append(string value)
private bool NeedsAllocation(string currentString, int requiredLength)
internal unsafe void AppendInPlace(string value, int currentLength)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int num1 = value.Length;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int num2 = currentLength + num1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fixed (char* chRef1 = &this.m_firstChar)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fixed (char* chRef2 = &value.m_firstChar)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string.wstrcpy(chRef1 + currentLength, chRef2, num1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
chRef1[num2] = '
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1357692
相关文章推荐
- [C#]几种字符串反转方法效率比较
- 几种字符串反转方法效率比较
- 几种字符串反转方法效率比较
- 几种字符串反转方法效率比较
- 几种字符串反转方法效率比较
- 几种字符串反转方法效率比较
- 几种字符串反转方法效率比较
- 比较C#中几种常见的复制字节数组方法的效率
- 黑马程序员_C#中几种比较字符串的方法比较
- C#反转字符串效率最高的方法
- C#反转字符串效率最高的方法
- C#判断字符串为空的几种方法和效率判断
- C#反转字符串效率最高的方法
- C#访问BitMap几种方法效率比较
- C#反转字符串效率最高的方法
- C#反转字符串效率最高的方法
- C#中判断字符串为空的几种方法的比较
- C#反转字符串效率最高的方法
- 关于字符串反转的几种方法的比较
- 几种C#框架提供的数据结构对以字符串为主键的单值查找的效率比较