C#关于类的新手提问
来源:百度知道 编辑:UC知道 时间:2024/05/25 12:22:46
建了一个类
protect class KeyWord
{
String key;
KeyWord next;
String getkey()
{ return key; }
KeyWord getnext()
{ return next; }
}
然后在函数中生成了一个对象
KeyWord head=new KeyWord();
但是怎么读取和修改head中的数据呢
head.key 的话不行, 提示是受保护级别限制..(调用的部分也是protect的)...
其实也不限于class,解决不了这个问题也无所谓,只是想写一个链表而已,望指点..
protect class KeyWord
{
String key;
KeyWord next;
public String getkey{
set{key=value;}
get{return key;} }
public KeyWord getnext
{ set{next=value;}
get{return next;} }
}
protect class KeyWord
{
String key;
KeyWord next;
String getkey()
{ return key; }
KeyWord getnext()
{ return next; }
}
这是什么乱七八糟的,你是想定义对象不,看我例子写
/// <summary>
/// 用户对象
/// </summary>
public class UserModel
{
private string _Username = String.Empty;
private int _Fd_employee_id = 0;
/// <summary>
/// 构造函数
/// </summary>
public UserModel()
{
}
/// <summary>