为什么这段代码显示“喜&QUOT ;.请提供解决方案。 [英] Why this code isshowing" hi". Kindly Provide Solution .

查看:85
本文介绍了为什么这段代码显示“喜&QUOT ;.请提供解决方案。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Why this code is showing" hi". Kindly Provide Solution 
         
        
        private void button1_Click(object sender, EventArgs e)
        {string s1 = textBox1.Text;
        if (s1[2] != 0)
        { MessageBox.Show("HI"); }
        else
            MessageBox.Show("nooo ");
        }

推荐答案

s1 [2] - >这是一个你想要检查的字符:



s1[2] - > this is a char you want to check like this :

 if (s1[2] != '0')
        { MessageBox.Show("HI"); }
        else
            MessageBox.Show("nooo ");


// or

 if (s1[2].ToString() != "0")
        { MessageBox.Show("HI"); }
        else
            MessageBox.Show("nooo ");


因为s1 [2]不等于0。
Because s1[2] is not equal to 0.


这篇关于为什么这段代码显示“喜&QUOT ;.请提供解决方案。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆