VB -> C# code

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

    #1

    VB -> C# code

    Could someone please tell me what the C# equivalent of this VB.NET code is:

    Dim aPropInfo() As System.Reflecti on.PropertyInfo

    aPropInfo = GetType(System. Drawing.Color). GetProperties



    This is what I came up with:

    Color dummy = new Color();

    System.Reflecti on.PropertyInfo[] aPropInfo =
    dummy.GetType() .GetProperties( );



    but maybe there is a more elegant way of getting the type without creating a
    dummy Color object?


  • Ignacio Machin \( .NET/ C#  MVP \)

    #2
    Re: VB -> C# code

    Hi Chris,

    System.Reflecti on.PropertyInfo[] apropinfo;

    apropinfo = Type.GetType( "System.Drawing .Color" ).GetProperties ();

    Hope this help,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation


    "Chris Becker" <slolife@hotmai l.com> wrote in message
    news:eOGLQ28oDH A.2140@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Could someone please tell me what the C# equivalent of this VB.NET code[/color]
    is:[color=blue]
    >
    > Dim aPropInfo() As System.Reflecti on.PropertyInfo
    >
    > aPropInfo = GetType(System. Drawing.Color). GetProperties
    >
    >
    >
    > This is what I came up with:
    >
    > Color dummy = new Color();
    >
    > System.Reflecti on.PropertyInfo[] aPropInfo =
    > dummy.GetType() .GetProperties( );
    >
    >
    >
    > but maybe there is a more elegant way of getting the type without creating[/color]
    a[color=blue]
    > dummy Color object?
    >
    >[/color]


    Comment

    • Tom Shelton

      #3
      Re: VB -&gt; C# code

      In article <eOGLQ28oDHA.21 40@TK2MSFTNGP09 .phx.gbl>, Chris Becker wrote:[color=blue]
      > Could someone please tell me what the C# equivalent of this VB.NET code is:
      >
      > Dim aPropInfo() As System.Reflecti on.PropertyInfo
      >
      > aPropInfo = GetType(System. Drawing.Color). GetProperties
      >
      >
      >
      > This is what I came up with:
      >
      > Color dummy = new Color();
      >
      > System.Reflecti on.PropertyInfo[] aPropInfo =
      > dummy.GetType() .GetProperties( );
      >
      >
      >
      > but maybe there is a more elegant way of getting the type without creating a
      > dummy Color object?
      >
      >[/color]


      PropertyInfo[] aPropInfo = typeof(System.D rawing.Color).G etProperties();

      HTH
      --
      Tom Shelton
      MVP [Visual Basic]

      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: VB -&gt; C# code

        Chris Becker <slolife@hotmai l.com> wrote:

        <snip>
        [color=blue]
        > but maybe there is a more elegant way of getting the type without creating a
        > dummy Color object?[/color]

        Yup: typeof(Color)

        --
        Jon Skeet - <skeet@pobox.co m>
        Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

        If replying to the group, please do not mail me too

        Comment

        • Chris Becker

          #5
          Re: VB -&gt; C# code

          Thanks to everyone who answered.

          I am going with Tom's answer since it will be checked by the compiler rather
          than at runtime ( I could misspell color colour)

          PropertyInfo[] aPropInfo = typeof(System.D rawing.Color).G etProperties();


          "Chris Becker" <slolife@hotmai l.com> wrote in message
          news:eOGLQ28oDH A.2140@TK2MSFTN GP09.phx.gbl...[color=blue]
          > Could someone please tell me what the C# equivalent of this VB.NET code[/color]
          is:[color=blue]
          >
          > Dim aPropInfo() As System.Reflecti on.PropertyInfo
          >
          > aPropInfo = GetType(System. Drawing.Color). GetProperties
          >
          >
          >
          > This is what I came up with:
          >
          > Color dummy = new Color();
          >
          > System.Reflecti on.PropertyInfo[] aPropInfo =
          > dummy.GetType() .GetProperties( );
          >
          >
          >
          > but maybe there is a more elegant way of getting the type without creating[/color]
          a[color=blue]
          > dummy Color object?
          >
          >[/color]


          Comment

          Working...