for (int i = 1; i < 5; i++)
{
var name = "radioButton" + i;
string n = this.Controls[name].Tag.ToString();
if (n == "Number")
{ MessageBox.Show("1111"); }
这句为什么报错“System.NullReferenceException”类型的未经处理的异常?
{
var name = "radioButton" + i;
string n = this.Controls[name].Tag.ToString();
if (n == "Number")
{ MessageBox.Show("1111"); }
这句为什么报错“System.NullReferenceException”类型的未经处理的异常?
解决方案 »
- .net 4.5中的异步问题~
- 字符串输入问题 求改正!!!
- 怎么用.net做个像QQ垂直菜单的呢?
- backgroundworker 如何及时添加后台事件
- 很简单的问题,如何在aspx.cs文件里,改变ascx.cs的一个值呢?高分.....................
- 请教一个郁闷的C#语句,不知道错在哪里,多谢各位
- dataset中fill方法报错-数组索引超出限界 ----急,在线等
- 顶者有分!!!!!!!快快快!!!
- ListView中加入文件图标的问题(UP有分)?
- 我做好了个C#程序,C/S结构,如何管理注册?
- 谁能帮忙能把一小段JAVA代码转C#?
- .net框架改变后 Process类不正常
首先呢?你刪除所有radioButton,然後就保留radioButton1,然後賦值radioButton1的Tag值,然後
for (int i = 1; i <2; i++)
這樣子能不能成功
首先呢?你刪除所有radioButton,然後就保留radioButton1,然後賦值radioButton1的Tag值,然後
for (int i = 1; i <2; i++)
這樣子能不能成功
这样可以 这是什么原理?
首先呢?你刪除所有radioButton,然後就保留radioButton1,然後賦值radioButton1的Tag值,然後
for (int i = 1; i <2; i++)
這樣子能不能成功
这样可以 这是什么原理?
判斷一下NULL值啊
for (int i = 1; i < 5; i++)
{
var name = "radioButton" + i;
if (this.Controls[name] != null)
{
if (this.Controls[name].Tag != null)
{
string n = this.Controls[name].Tag.ToString();
if (n == "Number")
{
MessageBox.Show("1111");
}
}
} }
肯定是this.Controls[name]为null
断点
this.Controls[name]
这个地方验证一下