首页 > 代码库 > 格式转换

格式转换

服务器的字符串一般是byte[]格式

byte[]转string(c#)

byte[] byteArray = System.Text.Encoding.Default.GetBytes(str);

string str = System.Text.Encoding.Default.GetString(byteArray);

byte[]转char[]

GetChars

 

uint转int

uint n = 3;

int i = checked((int)n); // throws OverflowException if n > Int32.MaxValue

int i = unchecked((int)n); // converts the bits only i will be negative if n > Int32.MaxValue

int i = (int)n; // same behavior as unchecked

or 

int i = Convert.ToInt32(n); // same behavior as checked

 

 

格式转换