c# - How to specify a class that may contain another class -
i want create class have class second class may different each time first class called. example:
public class serverresponseobject { public string statuscode { get; set; } public string errorcode { get; set; } public string errordescription { get; set; } public object obj { get; set; } public serverresponseobject(object obje) { obj = obje; } } public class tvchannelobject { public string number { get; set; } public string title { get; set; } public string favoritechannel { get; set; } public string description { get; set; } public string packageid { get; set; } public string format { get; set; } } public class channelcategoryobject { public string id { get; set; } public string name { get; set; } }
how can call serverresponseobject
different objects each time, once tvchannelobject
, once channelcategoryobject
?
what you're looking generic type parameter:
public class serverresponseobject<t> { public serverresponseobject(t obj) { obj = obj; } public t obj { get; set; } }
Comments
Post a Comment