2
I'm从VB和I'm总新C.未来我有2类:我怎样才能把“子类”一类
public class Location {
public decimal lat {get;set;}
public decimal lon {get;set;}
}
public class credentials {
public string username {get;set;}
public string passwordhash {get;set;}
}
现在我想用这2类在某些其他类别中,新类似如下:
public class something1 {
public string property1 {get;set;}
public string property2 {get;set;}
// next 2 lines should be avoided -> class "Location"
public decimal lat {get;set;}
public decimal lon {get;set;}
// next 2 lines should be avoided -> class "credentials"
public string username {get;set;}
public string passwordhash {get;set;}
}
我该如何认识到这一点?我不熟悉所有的OO东西。 感谢您的帮助。
不要忘记删除'username'和'passwordhash',太 –
如果我让这个样子,访问LON必须是:something1.Location.lon,对不对?但是我需要一些东西,因为我得到了序列化的json数据并且想将它存储在对象中。 –
已更新的答案。 – markmnl