# , .
Text null, TextBox1 null, .
, Textbox .
char , .
, , TextBox1.Text , length TextBox1.Text.
, . , (, ) .
If (Textbox1.Text.Length > 0) {
Button1.Enabled = string.IsWhitespace(Textbox1.Text);
Button1.Enabled = !(TextBox1.Text.ToList().Any(Char.IsWhitespace));
} else {
Button1.Enabled = False;
}
, (.. List ( char)) (.. All, Any, FindAll) .
, , ( ) TextBox.Text List(of string) :
List(of string) l_tb_RequiredText = {TextBox1.Text, TextBox2.Text, TextBox3.Text};
Button1.Enabled = !(l_tb_RequiredText.Any(string.IsNullEmptyWhitespace));
, - .
- () , "addressof" . ( ) #.. .
public bool hasSpaceInString(string value) {
return !(value.ToList().Any(Char.IsWhitespace));
}
...
List(of string) l_tb_RequiredText = {TextBox1.Text, TextBox2.Text, TextBox3.Text};
Button1.Enabled = !(l_tb_RequiredText.Any(hasSpaceInString));
, , - , ( delegate). IEnumerable, . IEnumerable(of string) List(of string), delegate, .
Additionally (starting with and C # 3.0) you can use lambda expressions to create delegateand attach it to an anonymous function at runtime.
http://msdn.microsoft.com/en-us/library/bb397687.aspx