473,322 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

VB -> C# code

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?
Nov 20 '05 #1
4 1456
Hi Chris,

System.Reflection.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" <sl*****@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP09.phx.gbl...
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?

Nov 20 '05 #2
In article <eO**************@TK2MSFTNGP09.phx.gbl>, Chris Becker wrote:
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
--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #3
Chris Becker <sl*****@hotmail.com> wrote:

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


Yup: typeof(Color)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 20 '05 #4
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();
"Chris Becker" <sl*****@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP09.phx.gbl...
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?

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ahmad | last post by:
Hi all, I have written a simple c++ app, as I'm still learning c++. The thing works flawlessly on VC++6, but just doesn't work on g++. The transliterate function which causes the problem is...
3
by: WØCBF | last post by:
I know this code has worked before but now appears to get a compile error. The code it seems to choke on line 12. I receive the following message and it highlights the "rst!" statement. Error...
14
by: TT (Tom Tempelaere) | last post by:
Hi people, The code that follows throws an ExecutionEngineException. This was written in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE 7.1 (7.1.3088). The framework is .NET...
2
by: Axel Dahmen | last post by:
HI, I want to dynamically add controls to a web page from within a common base class. Unfortunately, ASP.NET fails with "System.Web.HttpException: The Controls collection cannot be modified...
29
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form...
5
bartonc
by: bartonc | last post by:
Two new sub forums have been added to the Python Forum. These are NOT Q&A forums, but threads will be open to discussion. In Python > Python Code you will find snippets submitted by experts and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.