private object AB()
{
return new { A = 10,
B = "ac" };
}
private dynamic AB1()
{
return new { A = 10,
B = "ac" };
}
public static T
Cast<T>(object obj, T type)
{
return (T)obj;
}
protected void
Button1_Click(object sender, EventArgs e)
{
var c = new { A = 0,
B = "a" };
var v = Cast(AB(), c); //
Using Object dataType
string b = v.B;
var s = AB1(); // Using Dynamic dataType
var s = AB1(); // Using Dynamic dataType
string a = s.A;
}
No comments:
Post a Comment