How to assign Partial Values in a C# object using Inline Assignment -


i'm having collection of model

public class mobilemodelinfo {     public string name { get; set; }     public string catagory { get; set; }     public string year { get; set; } }  public class mainclass {     public mainclass()     {         mobilemodelinfo mobobject = new mobilemodelinfo();         mobobject.name = "apple iphone 6";         setmobiledetails(mobobject);     }      private void setmobiledetails(mobilemodelinfo mobobject)     {         mobobject.catagory = "ultra smart phone";         mobobject.year = "2015";     } } 

in setmobiledetails() method set partial values object of mobilemodelinfo. here need assign values via inline. how can achieve this

for example: new mobilemodelinfo() { catagory = "ultra smart phone", year = "2015" }

kindly assist me...

note: 1 of property set in constructor , remaining properties going set in setmobiledetails() method.

use below code solve problem thank you.

void setmobiledetails(string catagory string year ) {      new mobilemodelinfo() { catagory = "ultra smart phone", year = "2015" }  } 

also make overload of when property change below

 void setmobiledetails(string catagory)     {          new mobilemodelinfo() { catagory = "ultra smart phone"}      } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -