473,385 Members | 1,324 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,385 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 15 '05 #1
4 1150
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 15 '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 15 '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 15 '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 15 '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...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.