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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

android - IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling -