编写一个员工类,定义员工姓名和年龄字段,通过访问属性,实现读取和写入员工信息,并输出相关信息。 编写一个员工类,定义员工姓名和年龄字段,通过访问属性,实现读取和写入员工信息,并输出相关信息。用C#语言怎么编写?急!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class User{ string name; int age; public string Name { get {return name;} set{name=value;} } public int Age { get{return age;} set{age=value;} }}void Main(){ User u=new User(); u.Name="Tim"; u.Age=88; Console.WriteLine(u.Name +" : "+u.Age); }/*Tim : 88*/ public class Users { /// <summary> /// 用户名字 /// </summary> public string UserName { get; set; } /// <summary> /// 用户年龄 /// </summary> public int UserAge { get; set; } } public class Manage { public void PrintUser() { Users us = new Users() { UserName="UserName", UserAge=21 }; Console.WriteLine("姓名:"+us.UserName); Console.WriteLine("年龄:" + us.UserAge); } } public class Employee{ public string Name{get;set} public int Age{get;set}}... ...void Main(){ Employee emp=new Employee(Name="zhang",Age=10);} public class User{ public string Name { get ; set; } public int Age { get; set; }}void Main(){ User u=new User(); u.Name="Tim"; u.Age=88; Console.WriteLine(u.Name +" : "+u.Age);}这样应该可以吧 namespace PReadExecel{ class Employee { private string employeeID; public string EmployeeID { get { return employeeID; } set { employeeID = value; } } private string employeeName; public string EmployeeName { get { return employeeName; } set { employeeName = value; } } public override string ToString() { return "员工ID:" + employeeID + " 员工姓名:" + employeeName; } }} private void button2_Click(object sender, EventArgs e) { Employee employee = new Employee(); employee.EmployeeID = this.textBox1.Text.Trim(); employee.EmployeeName = this.textBox2.Text.Trim(); MessageBox.Show(employee.ToString()); } 新手求助 在线考试系统 怎么会这样??? 终于调通了。数独的C#求解程序! c# webbrowser控件载完一个页面后,如何将此页面的图片从内存中读出? c# 对话框问题 谁能提供图片显示的效果的思路或者代码,就像幻灯片那种效果! onPrintPage()问题 C#winform下能否进行两个access下的数据关联查询,高分求解! 求救关于批量上传文件 (asp.net c# 分不够 可以再给) 高分求如何解决文本框回车事件 关于帮助文件弹出问题 C#做企业人事信息管理系统,有人能提供一个类似的系统给我做参考吗?
{
string name;
int age;
public string Name
{
get {return name;}
set{name=value;}
}
public int Age
{
get{return age;}
set{age=value;}
}
}void Main()
{
User u=new User();
u.Name="Tim";
u.Age=88;
Console.WriteLine(u.Name +" : "+u.Age);
}/*
Tim : 88
*/
{
/// <summary>
/// 用户名字
/// </summary>
public string UserName { get; set; } /// <summary>
/// 用户年龄
/// </summary>
public int UserAge { get; set; }
} public class Manage
{
public void PrintUser()
{
Users us = new Users() { UserName="UserName", UserAge=21 }; Console.WriteLine("姓名:"+us.UserName); Console.WriteLine("年龄:" + us.UserAge);
}
}
{
public string Name{get;set}
public int Age{get;set}}
... ...
void Main()
{
Employee emp=new Employee(Name="zhang",Age=10);
}
{
public string Name
{
get ;
set;
}
public int Age
{
get;
set;
}
}
void Main()
{
User u=new User();
u.Name="Tim";
u.Age=88;
Console.WriteLine(u.Name +" : "+u.Age);
}
这样应该可以吧
namespace PReadExecel
{
class Employee
{
private string employeeID;
public string EmployeeID
{
get { return employeeID; }
set { employeeID = value; }
} private string employeeName;
public string EmployeeName
{
get { return employeeName; }
set { employeeName = value; }
} public override string ToString()
{
return "员工ID:" + employeeID + " 员工姓名:" + employeeName;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
Employee employee = new Employee();
employee.EmployeeID = this.textBox1.Text.Trim();
employee.EmployeeName = this.textBox2.Text.Trim();
MessageBox.Show(employee.ToString());
}