VB -> C# code

  • Thread starter Thread starter Chris Becker
  • Start date Start date
C

Chris Becker

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

Dim aPropInfo() As System.Reflection.PropertyInfo

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



This is what I came up with:

Color dummy = new Color();

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



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

System.Reflection.PropertyInfo[] apropinfo;

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

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

Dim aPropInfo() As System.Reflection.PropertyInfo

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



This is what I came up with:

Color dummy = new Color();

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



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


PropertyInfo[] aPropInfo = typeof(System.Drawing.Color).GetProperties();

HTH
 
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.Drawing.Color).GetProperties();
 
Back
Top