Search Results

Search found 1 results on 1 pages for 'user1888033'.

Page 1/1 | 1 

  • Extend base class properties

    - by user1888033
    I need your help to extend my base class, here is the similar structure i have. public class ShowRoomA { public audi AudiModelA { get; set; } public benz benzModelA { get; set; } } public class audi { public string Name { get; set; } public string AC { get; set; } public string PowerStearing { get; set; } } public class benz { public string Name { get; set; } public string AC { get; set; } public string AirBag { get; set; } public string MusicSystem { get; set; } } //My Implementation class like this class Main() { private void UpdateDetails() { ShowRoomA ojbMahi = new ShowRoomA(); GetDetails( ojbMahi ); // this works fine } private void GetDetails(ShowRoomA objShowRoom) { objShowRoom = new objShowRoom(); objShowRoom.audi = new audi(); objShowRoom.audi.Name = "AUDIMODEL94CD698"; objShowRoom.audi.AC = "6 TON"; objShowRoom.audi.PowerStearing = "Electric"; objShowRoom.benz= new benz(); objShowRoom.audi.Name = "BENZMODEL34LCX"; objShowRoom.audi.AC = "8 TON"; objShowRoom.audi.AirBag = "Two (1+1)"; objShowRoom.audi.MusicSystem = "Poineer 3500W"; } } // Till this cool. // Now I got requirement for ShowRoomB with replacement of old audi and benz with new models and new other brand cars also added. // I don't want to modify GetDetails() method. by reusing this method additional logic i want to apply to my new extended model. // Here I struck in designing my new model of ShowRoomB (base of ShowRoomA) ... I have tried some thing like... but not sure. public class audiModelB:audi { public string JetEngine { get; set; } } public class benzModelB:benz { public string JetEngine { get; set; } } public class ShowRoomB { public audiModelB AudiModelB { get; set; } public benzModelB benzModelB { get; set; } } // My new code to Implementation class like this class Main() { private void UpdateDetails() { ShowRoomB ojbNahi = new ShowRoomB(); GetDetails( ojbNahi ); // this is NOT working! I know this object does not contain base class directly, still some what i want fill my new model with old properties. Kindly suggest here } } Can any one please give me solutions how to achieve my extending requirement for base class "ShowroomA" Really appreciated your time and suggestions. Thanks in advance,

    Read the article

1