首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

怎么比较字符串是忽略大小写

2013-04-12 
如何比较字符串是忽略大小写?using Systemusing System.Collections.Genericusing System.ComponentMode

如何比较字符串是忽略大小写?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
#region 吴新强于2013年4月10日10:55:03 桂电 2507
#endregion
namespace Compares
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 比较字符串是忽略大小写
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        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);
        }
    }
}

 

怎么比较字符串是忽略大小写

热点排行