在VB.NET中我写这样的代码dim a as string = me.textbox1.text
dim b as bool=false
me.textbox1.readonly=trueif a="条件1成立" then    b=true
    me.textbox1.readonly=falseend if在C#中怎么实现?主要是在达到条件后把布尔型的FALSE改成TRUE.

解决方案 »

  1.   

    string a = me.textbox1.text ;
    bool b=false; 
    this.textbox1.readonly=true ;if (a=="条件1成立" )
    {
        b=true ;
        this.textbox1.readonly=false; 
    }
     
      

  2.   

    楼上的方法我在Microsoft Visual Studio 2005中试过了,运行前出现一个错误提示,变量某某已赋值,但其值从未使用过.不知怎么回事.在VB.NET中就没有这问题.
      

  3.   

    string a = this.textbox1.text;
    bool b=false;
    this.textbox1.readonly=true;if (a=="条件1成立" ) 

        b=true; 
        this.textbox1.readonly=false;
      

  4.   

    这个应该是警告吧,不是错误,不管他。
    string a = this.textbox1.text; 
    bool b=false; 
    this.textbox1.readonly=true; if (a.Equals("条件1成立" )) 

        b=true; 
        this.textbox1.readonly=false; 
    } 字符串相等不用==