请帮我更正我的代码。 [英] Help correct my codes for me please.
本文介绍了请帮我更正我的代码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试清除一组TextBoxes的初始内容(下面的代码集)正常工作:
y = ActiveControl.Text;
if(y ==A|| y ==B|| y ==C|| y ==D)
{
ActiveControl.Text =的String.Empty;
}
但是这另一套不起作用:
if(ActiveControl []。Text.Contains(A,B,C ,D))
{
ActiveControl.Text = string.Empty;
}
虽然我更喜欢最后一组代码到第一组。
有人帮帮我。
谢谢。
解决方案
麻烦的是第二个版本无法编译。你可以试试这个:
私人 静态 string [] validList = new string [] { , B, C,< span class =code-string> D};
...
if (validList.Contains(ActiveControl.Text))
{
...
}
Trying to clear initial content of a group of TextBoxes, the set of codes below, is working: y = ActiveControl.Text; if (y == "A" || y == "B" || y == "C" || y =="D") { ActiveControl.Text = string.Empty; } But this other set is not working: if (ActiveControl[].Text.Contains("A", "B", "C", "D)) { ActiveControl.Text = string.Empty; } Though I prefer the last set of codes to the 1st one. Somebody help me out please. Thanks.
解决方案
The trouble is that the second version won't compile. You could try this:
private static string[] validList = new string[] { "A", "B", "C", "D" }; ... if (validList.Contains(ActiveControl.Text)) { ... }
这篇关于请帮我更正我的代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文