(Beginner) VB.NET piece of code, How is it coded in C#?

G

Guest

Hello Fellows,

Can you let me know how do i convert the below VB.NET piece of code into c#?

Dim targetTypes(0) as Type
targetTypes(0) = GetType(Order)

Thanks :)
 
F

Frans Bouma [C# MVP]

NewBie said:
Hello Fellows,

Can you let me know how do i convert the below VB.NET piece of code into c#?

Dim targetTypes(0) as Type
targetTypes(0) = GetType(Order)

Type[] targetTypes = new Type[1];
targetTypes[0] = GetType(Order);

FB, who wonders what this has to do with ADO.NET ;)
 
C

clintonG

[raising hand and waving wildly]
I do! I do!

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/



Frans Bouma said:
NewBie said:
Hello Fellows,

Can you let me know how do i convert the below VB.NET piece of code into c#?

Dim targetTypes(0) as Type
targetTypes(0) = GetType(Order)

Type[] targetTypes = new Type[1];
targetTypes[0] = GetType(Order);

FB, who wonders what this has to do with ADO.NET ;)
 
G

Guest

Hi FB,
Thanks for the reply, i had tried that but i get the below compilation error...
'NameSpace.Order' denotes a 'class' where a 'variable' was expected.
Then realised that get type takes in a string, (type name) in C#

BTW.. ADO.NET? i posted the Q in the NG "microsoft.public.dotnet.languages.csharp"

Tnx once again...


Frans Bouma said:
NewBie said:
Hello Fellows,

Can you let me know how do i convert the below VB.NET piece of code into c#?

Dim targetTypes(0) as Type
targetTypes(0) = GetType(Order)

Type[] targetTypes = new Type[1];
targetTypes[0] = GetType(Order);

FB, who wonders what this has to do with ADO.NET ;)
 
M

Marc Selis

The VB.NET GetType() function is called typeof() in C#

Your example then becomes:
Type[] targetTypes = new Type[1];
targetTypes[0] = typeof(Order);

or shorter:

Type[] targetTypes = new Type[] {typeof(Order)};



NewBie said:
Hi FB,
Thanks for the reply, i had tried that but i get the below compilation error...
'NameSpace.Order' denotes a 'class' where a 'variable' was expected.
Then realised that get type takes in a string, (type name) in C#

BTW.. ADO.NET? i posted the Q in the NG "microsoft.public.dotnet.languages.csharp"

Tnx once again...


Frans Bouma said:
NewBie said:
Hello Fellows,

Can you let me know how do i convert the below VB.NET piece of code into c#?

Dim targetTypes(0) as Type
targetTypes(0) = GetType(Order)

Type[] targetTypes = new Type[1];
targetTypes[0] = GetType(Order);

FB, who wonders what this has to do with ADO.NET ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top