c# - Use object name to return value of a specific property -


is there method object name return specified property value variable. example have following class

class class1 {     int valint;     double valdouble;     string valstring;     public class1(int intvalue)     {         valint = intvalue;     }      public class1(double doublevalue)     {         valdouble = doublevalue;     }      public class1(string stringvalue)     {         valstring = stringvalue;     }         } 

so when use object this

        list<class1> list = new list<class1>();          list.add(new class1(25));         list.add(new class1(3.15));         list.add(new class1("name"));          foreach (class1 item in list)         {             console.writeline(item); -> outputs 25, 3.15, name         } 


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -