Class Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric

    #1

    Class Question

    I have created a class based on an XML file using the XSD.exe .Net utility
    program. The class has all of the XML elements as properties of the class.
    I am wanting create a way to loop through each property based on the string
    name. Basically, the xml file will be deserialized into the class object
    and then I want to be able to loop through it. How can I do this?

    Thanks


  • Dmitriy Lapshin [C# / .NET MVP]

    #2
    Re: Class Question

    Hi Eric,

    You can do that by using methods of the System.Type class and the classes
    returned that belong to the System.Reflecti on namespace.

    --
    Dmitriy Lapshin [C# / .NET MVP]
    X-Unity Test Studio

    Bring the power of unit testing to VS .NET IDE

    "Eric" <spam@hotmail.c om> wrote in message
    news:O6l3vpxoDH A.2012@TK2MSFTN GP12.phx.gbl...[color=blue]
    > I have created a class based on an XML file using the XSD.exe .Net utility
    > program. The class has all of the XML elements as properties of the[/color]
    class.[color=blue]
    > I am wanting create a way to loop through each property based on the[/color]
    string[color=blue]
    > name. Basically, the xml file will be deserialized into the class object
    > and then I want to be able to loop through it. How can I do this?
    >
    > Thanks
    >
    >[/color]

    Comment

    • Eric

      #3
      Re: Class Question

      Thanks for your reply. Is there an example that I could see?

      Thanks

      "Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam-please.hotpop.c om> wrote
      in message news:%23mkw1y6o DHA.3688@TK2MSF TNGP11.phx.gbl. ..[color=blue]
      > Hi Eric,
      >
      > You can do that by using methods of the System.Type class and the classes
      > returned that belong to the System.Reflecti on namespace.
      >
      > --
      > Dmitriy Lapshin [C# / .NET MVP]
      > X-Unity Test Studio
      > http://x-unity.miik.com.ua/teststudio.aspx
      > Bring the power of unit testing to VS .NET IDE
      >
      > "Eric" <spam@hotmail.c om> wrote in message
      > news:O6l3vpxoDH A.2012@TK2MSFTN GP12.phx.gbl...[color=green]
      > > I have created a class based on an XML file using the XSD.exe .Net[/color][/color]
      utility[color=blue][color=green]
      > > program. The class has all of the XML elements as properties of the[/color]
      > class.[color=green]
      > > I am wanting create a way to loop through each property based on the[/color]
      > string[color=green]
      > > name. Basically, the xml file will be deserialized into the class[/color][/color]
      object[color=blue][color=green]
      > > and then I want to be able to loop through it. How can I do this?
      > >
      > > Thanks
      > >
      > >[/color]
      >[/color]


      Comment

      • Dmitriy Lapshin [C# / .NET MVP]

        #4
        Re: Class Question

        Please refer to the "Type.GetMethod s Method" topic in MSDN.

        --
        Dmitriy Lapshin [C# / .NET MVP]
        X-Unity Test Studio

        Bring the power of unit testing to VS .NET IDE

        "Eric" <spam@hotmail.c om> wrote in message
        news:%23tyQbd7o DHA.3320@tk2msf tngp13.phx.gbl. ..[color=blue]
        > Thanks for your reply. Is there an example that I could see?
        >
        > Thanks
        >
        > "Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam-please.hotpop.c om> wrote
        > in message news:%23mkw1y6o DHA.3688@TK2MSF TNGP11.phx.gbl. ..[color=green]
        > > Hi Eric,
        > >
        > > You can do that by using methods of the System.Type class and the[/color][/color]
        classes[color=blue][color=green]
        > > returned that belong to the System.Reflecti on namespace.
        > >
        > > --
        > > Dmitriy Lapshin [C# / .NET MVP]
        > > X-Unity Test Studio
        > > http://x-unity.miik.com.ua/teststudio.aspx
        > > Bring the power of unit testing to VS .NET IDE
        > >
        > > "Eric" <spam@hotmail.c om> wrote in message
        > > news:O6l3vpxoDH A.2012@TK2MSFTN GP12.phx.gbl...[color=darkred]
        > > > I have created a class based on an XML file using the XSD.exe .Net[/color][/color]
        > utility[color=green][color=darkred]
        > > > program. The class has all of the XML elements as properties of the[/color]
        > > class.[color=darkred]
        > > > I am wanting create a way to loop through each property based on the[/color]
        > > string[color=darkred]
        > > > name. Basically, the xml file will be deserialized into the class[/color][/color]
        > object[color=green][color=darkred]
        > > > and then I want to be able to loop through it. How can I do this?
        > > >
        > > > Thanks
        > > >
        > > >[/color]
        > >[/color]
        >
        >[/color]

        Comment

        Working...