C#中的字符串比较
来源:互联网 发布:担保行业 知乎 编辑:程序博客网 时间:2024/05/18 02:09
C#中的字符串比较
今天遇到了C#的字符串比较的问题,下面我们就来看看C#中的字符串怎么比较。
1>Str.Equals(“字符串”);
2>String.Compare(Str1, Str2) == 0
3> Str1.CompareTo(Str2) == 0
4>3. str1 == str2
String.Equals方法已经重载了,和==是一样的效果。
下面是我实际项目中碰到的:
/// <summary>
/// 点击按钮“机台查询”触发的方法。
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
///
private void BtnCXJT_Click(object sender, EventArgs e) {
if(this.BtnCX.Text.Equals("机台查询")){
this.dgSbDetail.Visible = false;
this.BtnCX.Text = "查询明细";
this.BtnCX.BackColor = SystemColors.Info;
this.GetLySbDetail(this.str_sbid, this.str_sbname);
this.BtnCX.BackColor = Color.Lime;
this.txtBarcode.SelectAll();
this.txtBarcode.Focus();
}
else if (this.BtnCX.Text.Equals("隐藏明细"))
{
this.dgSbDetail.Visible = false;
this.txtBarcode.Enabled = true;
this.BtnCX.Text = "查询明细";
this.BtnCX.BackColor = Color.Lime;
this.txtBarcode.SelectAll();
this.txtBarcode.Focus();
}
else if (this.BtnCX.Text.Equals("查询明细"))
{
this.dgSbDetail.Visible = true;
this.GetLyDetail(this.str_sbid, GlobalPara.accountid);
this.BtnCX.Text = "隐藏明细";
this.BtnCX.BackColor = SystemColors.Info;
}
}
- C#中的字符串比较
- c#中的字符串的比较
- C#字符串比较
- C#字符串比较方法
- C#字符串比较方法
- C#字符串的比较
- C# 比较字符串
- C# 字符串比较 效率
- C#字符串比较
- C#比较字符串
- c# IComparer比较字符串
- Java中的字符串比较
- ORACLEz中的字符串比较
- JavaScript 中的字符串比较
- C#中的日期比较
- C#中的比较
- C#中的比较
- C#中的几个比较
- 求和 sum
- Android数据库改变监听,ContentObserver使用
- MFC六大核心机制之三:动态创建
- LeetCode 104. Maximum Depth of Binary Tree
- Scrapy ——自动多网页爬取(抓取某人博客所有文章)(四)
- C#中的字符串比较
- QT简单编程
- C++静态库与动态库
- oracle怎么查询当前用户,有多少张表
- BZOJ 3012/Luogu 3065 [Usaco2012 Dec]First!
- LeetCode 258. Add Digits
- Bootstrap3modal嵌套|模态框嵌套滚动条bug
- android系统旋转方向定制问题
- caffe 安装