C# initialisiert die Eigenschaft list

Bin mit unter-Klassen...wie kann ich die Initialisierung mit einige Werte

Meine Frage ist, wie kann ich die Initialisierung über RootObject mit einige Werte in Main
Zum Beispiel

    Rootobject robj = new Rootobject();
    robj.inchistor.Add()     



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace JsonSample3
    {

        public class Customerinfo
        {
            public string customername { get; set; }
            public string address { get; set; }
            public string postcode { get; set; }
        }

        public class Inchistory
        {

            public Customerinfo customerinfo { get; set; }
            public string r { get; set; }
            public string reference { get; set; }
            public string region { get; set; }

        }

        public class RootObject
        {
            public List<Inchistory> inchistory { get; set; }
        }


    }

    class Program
    {
            static void Main(string[] args)
            {
               RootObject robj = new RootObject{ r = "", }

            }
    }



   Am having above classes namely CustomerInfo, Inchistory and Rootobject
InformationsquelleAutor raajesh | 2014-09-18
Schreibe einen Kommentar