//byte[] sby = System.Text.Encoding.Unicode.GetBytes("宁绍");
//string str = "";
//for (int i = 0; i < sby.Length; i++)
//{
// str += sby[i].ToString() + ",";
//}
//Label1.Text = str;
// String a = "159343536267578990074874";
// String a1="";
// char temp;
//int b = a.Length;
//char[] c = a.ToCharArray();
//for(int i=0;i<b;i++)
// for (int j=0;j<b-i-1 ; j++)
// {
// if (c[j]>=c[j+1])
// {
// temp = c[j];
// c[j] = c[j+1];
// c[j+1] = temp;
// }
// }
// for(int k=0;k<b;k++)
//{
// this.Label1.Text=c[k].ToString()+",";
//}
//string str = "Hello";
//string strRev = "";
//char[] se = str.ToCharArray();
//int len = se.Length;
////se=(char[])Array.Reverse(se);
//for (int i = len - 1; i >= 0; i--)
//{
// strRev += se[i].ToString();
//}
////string strRev = new string();
//this.Label1.Text = strRev;
//string str = "Hello你好";
//char[] se = str.ToCharArray();
//Array.Reverse(se);
//string strRev = new string(se);
//decimal strRev = 'a'/ 'b';
////strRev = 127 / 2;
//this.Label1.Text = strRev.ToString();
// reserve();
private void reserve()
{
string str = "a";
//System.Collections.Generic.Stack<char> cStack = new System.Collections.Generic.Stack<char>(str);
//while (cStack.Count > 0)
//{
// this.Label1.Text += cStack.Pop().ToString();
//}
//System.Text.StringBuilder str = new System.Text.StringBuilder("hello");
// char temp;
// for (int i = 0; i < str.Length / 2; i++)
// {
// temp = str[i];
// str[i] = str[str.Length - 1 - i];
// str[str.Length - 1 - i] = temp;
// }
// this.Label1.Text = str.ToString();
if (str == null)
{
return ;
}
if (str.Length == 0)
{
return ;
}
char[] data = str.ToCharArray();
int iLeft = 0;
int iRight = data.Length - 1;
while (true)
{
if (iRight >= 0 && iLeft < iRight)
{
char temp = data[iLeft];
data[iLeft] = data[iRight];
data[iRight] = temp;
}
else
{
break;
}
iLeft++;
iRight--;
}
String newStr = new String(data);
this.Label1.Text = newStr;
}
评论