c#备忘知识点

1.比较字符串

 

private void button1_Click(object sender, EventArgs e)
        {
            if(string.Compare(textBox1 .Text .ToLower (),textBox2.Text.ToLower())<0)
            MessageBox.Show ("字符串1小于字符串2","信息",MessageBoxButtons.OK,MessageBoxIcon.Information );

            if (string.Compare(textBox1.Text.ToLower(), textBox2.Text.ToLower()) == 0)
                MessageBox.Show("字符串1等于字符串2", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);

            if (string.Compare(textBox1.Text.ToLower(), textBox2.Text.ToLower()) > 0)
                MessageBox.Show("字符串1大于字符串2", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

 

 

2.日期年月日

 

 

DateTime dt1 = new DateTime(n1+60, y1, r1);
TimeSpan ts = dt1 - DateTime.Now;
Console.WriteLine("从现在到其60周岁期间,总共{0}天",ts.Days.ToString ());

 

 

3.XMLHTTP向服务器端发送和接受的压缩的字符串(字节传送)

发送:str=UnicodeEncoding.UTF8.GetBytes(p_sStr);
接收:Object =UnicodeEncoding.GetEncoding(936).GetString((byte[])http.responseBody);


 

 

posted @ 2013-05-04 21:02  javawebsoa  Views(133)  Comments(0Edit  收藏  举报