from1包含变量"Admin_id"; n当我编码form1 f1 = new form1()时,它变为null.为什么? [英] from1 contains a variable "Admin_id" n it becomes null when i code form1 f1 = new form1(); why?
本文介绍了from1包含变量"Admin_id"; n当我编码form1 f1 = new form1()时,它变为null.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
from1包含一个变量"Admin_id" n我这样声明它
from1 contains a variable "Admin_id" n i declare it like this
private string admin_id;
public string Admin_id
{
get { return admin_id; }
set { admin_id = value; }
}
当我为
it becomes null when i code
form1 f1 = new form1();
编写代码时,它变为空吗?
我将其写在Administration类中以访问form1变量(admin_id)n的值以访问我的代码
why?
i write this in Administration class to access value of form1 variable (admin_id) n to access i code
string d_id = f1.Admin_id;
推荐答案
Admin_id是form1上的公共变量,因此当您创建表单的新实例时,将自动重新初始化所有变量
Admin_id is a public variable on the form1, so whenevr you create a new instance of the form then automatically all the variables are reinitialized
用于公共类型变量,使用类并定义如下:-
for Public type variables use class and define like this :-
public static string Admin_id;
用途:
uses :
string ID=classname.Admin_id;
替换
replace
admin_id. = A_TB1.Text;
与此:
with this:
string admin_id = A_TB1.Text;
有关更多查询,请在此处评论!!!
for further queries comment here!!
这篇关于from1包含变量"Admin_id"; n当我编码form1 f1 = new form1()时,它变为null.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文