TypeOf运算和CTYPE代码等同于C#

有人可以帮助我的等价代码为C#TypeOf运算和CTYPE代码等同于C#

Public Sub ClearTextBox(ByVal root As Control) 

For Each ctrl As Control In root.Controls

ClearTextBox(ctrl)

If TypeOf ctrl Is TextBox Then

CType(ctrl, TextBox).Text = String.Empty

End If

Next ctrl

End Sub

回答:

public void ClearTextBox(Control root) 

{

foreach (Control ctrl in root.Controls)

{

ClearTextBox(ctrl);

if (ctrl is TextBox)

{

ctrl.Text = string.Empty;

}

}

}

以上是 TypeOf运算和CTYPE代码等同于C# 的全部内容, 来源链接: utcz.com/qa/260537.html

回到顶部