您的位置:首页 > 编程语言 > C#

[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)
...{


int num1 = value.Length;


int num2 = currentLength + num1;


fixed (char* chRef1 = &this.m_firstChar)




...{


fixed (char* chRef2 = &value.m_firstChar)




...{


string.wstrcpy(chRef1 + currentLength, chRef2, num1);


}


chRef1[num2] = '

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1357692
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: