المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Type declaration ?



C# Programming
06-11-2009, 12:00 AM
Heres what I do now
Type a = b.GetType();
if (a.Name == "Blog")
{
Console.WriteLine("blog = {0}", ((Blog)b).text);
error = "ok";
return 0;
}
if (a.Name == "String")
{
Console.WriteLine("blog = {0}", (String)b);
error = "ok";
return 0;
}
Console.WriteLine("blog = TypeError");
error = "unKnownType";
return 1;

I want to set the type similar to this
((GetType())b).text
How can I do this ?