How to access members of class from a page Load class in c# -
i have 2 classes in project below:
//class public class carhelper { public class car { public string colour {get;set;} public string manufacturer {get;set;} } public car getdetails() { car c = new car(); var query = //querying db here c.colour = query.colour; c.manufacturer= query.manufaturer; return c; } } //class b //here have page load method this: protected void page_load(object sender, eventargs e) { carhelper car = new carhelper(); var getcarmanufacturer = car.manufacturer; //<< stuck here //how car manufacturer here above? }
as can see above, whats best way access members class a?
since you've created getdetails()
method public
can use retrieve car
object :
carhelper carhelper = new carhelper(); car car = carhelper.getdetails(); var carmanufacturer = car.manufacturer;
Comments
Post a Comment