1.You should overwrite the method
ToString()
in your
EmployeeInfo
class:
public class EmployeeInfo
{
public string ename;
public int eid;
public override string ToString()
{
return string.Format("ename = \"{0}\" , eid = {1}",
this.ename,
this.eid);
}
}
2.You should refine/simplify the code from
Button1_Click
like this:
protected void Button1_Click(object sender, EventArgs e)
{
EmployeeInfo obj = new EmployeeInfo { ename= "abc", eid = 123 };
Response.Write(obj.ToString());
}