代码改变世界

C# 知识点收集

2014-02-17 22:36  每天努力一点点  阅读(191)  评论(0编辑  收藏  举报

1. 数组复制

byte[] source;
byte[] dest;
int srcOffset = 0;
int dstOffset = 0;
int count = 10;
System.Buffer.BlockCopy(source, srcOffset, dest, dstOffset, count);
2.string转字节数组

byte[] inputByte = System.Text.Encoding.Unicode.GetBytes(text);
byte[] inputByte = System.Text.Encoding.ASCII.GetBytes(text);

3.字节数组转string

string str= System.Text.Encoding.UTF8.GetString(bytes);

4.windows换行符

Environment.NewLine

5.string转int

string str = "100";
int a = System.Int32.Parse(str);

6.判断Enter键是否按下

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
    if(e.KeyCode == Keys.Enter)
    {
        MessageBox.Show("keydown");
    }
}

7.