我有类:后来如何使用属性使用字符串值,从一类到另一个类
string url = li1.Value;
pro itm = new pro(); // I have create Proprtie so I'm calling that
itm.SetURL(url); // here I'm setting value
然后:
public class pro {
private string url = string.Empty;
public string GetURL() { return url; }
public void SetURL(string value) { url = value; }
}
在这一行我得到价值
pro itm = new pro(); //properties object I have created
string url = itm.GetURL(); // I'm not getting value which I have set in first class.
我也曾经创建的属性;我究竟做错了什么?
告诉我怎么一流的我的字符串值到达第二级使用性能。告诉我,我正在尝试的代码,但无法做到这一点。
“我究竟做错了” - 命名类“亲”和变量“ITM”为你希望其他人阅读代码是definitly之一这些事。 – 2012-03-16 05:28:30
当你说“then later”时,你的意思是代码是以不同的方法运行还是运行在不同的页面上? – patmortech 2012-03-16 05:40:36
你已经在这里问完全相同的问题,并没有接受答案http://stackoverflow.com/questions/9715520/why-are-my-values-not-being-kept-between-instances-of-a -type – Divi 2012-03-16 06:23:36