【问题标题】:how can i execute this in C# can someone help me我如何在 C# 中执行此操作 有人可以帮我吗
【发布时间】:2015-11-20 09:32:38
【问题描述】:

如何在 C# 中执行此操作

if txtbxquantity.text <=5     
then    
    txtbxhighlowitem.text = low item    
else    
    txtbxhighlowitem.text = high item    
end if    

【问题讨论】:

  • 你用过 C# 编程吗?
  • 不,先生..您能帮帮我吗?先生
  • 您应该从 C# 初学者教程开始。这可能是第一章的一部分。
  • 这里有一个很棒的教程:mottishaked.com/training/dot-net-tutorial

标签: c#


【解决方案1】:

接下来可能你想做:

int lowitem=0;
int highitem=0;
if(Convert.ToInt32(txtbxquantity.Text)<=5)
    lowitem = Covnert.ToInt32(txtbxhighlowitem.Text);
else 
    highitem = Covnert.ToInt32(txtbxhighlowitem.Text);

    private void button1_Click(object sender, EventArgs e)
    {
        string lowitem = "low item";
        string highitem = "high item";
        if (Convert.ToInt32(txtbxquantity.Text) <= 5)
            txtbxhighlowitem.Text = lowitem;
        else
            txtbxhighlowitem.Text = highitem;
    }

【讨论】:

  • 字符串 lowitem = "lowitem";字符串highitem =“highitem”; if (Convert.ToInt32(textquantity.Text)
  • 如果您输入的不是数字 (0-9) 符号,如 'a'、'b' 等,可能会发生这种情况。如果您需要文本框数据短于 5 个符号,请更改 if 条件:if( txtbxquantity.Text.lenght
【解决方案2】:

if (txtbxquantity.Text <= "5")
        {
            txtbxhighlowitem.Text = "low item";
        }
        else
        {
            txtbxhighlowitem.Text = "high item";
        }

【讨论】:

    猜你喜欢
    • 2018-07-24
    • 2010-10-29
    • 1970-01-01
    • 2013-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多