VB.Net to C# Question

G

Guest

Hi!

How can I convert the code below (VB.Net) to C#?

Dim c As New ArrayList
Return CType(c.ToArray(GetType(HistoryInfo)), HistoryInfo())

Where "HistoryInfo" is a common class.

Thanks,
Bruno.
 
C

Cteniza

Bruno Rodrigues said:
Hi!

How can I convert the code below (VB.Net) to C#?

Dim c As New ArrayList
Return CType(c.ToArray(GetType(HistoryInfo)), HistoryInfo())

Where "HistoryInfo" is a common class.

something like this

ArrayList c = new ArrayList();
return (HystoryInfo) c.ToArray(GetType(HistoryInfo));
 
G

Guest

But then I got a problem in

GetType(ProdutosInfo)

The compiler asks for a variable, not a class.
 
J

Jimi

The vb to c# converter Instant C# yields:

ArrayList c = new ArrayList();
return (HistoryInfo[])(c.ToArray(typeof(HistoryInfo)));

(I used to do this stuff by hand too)

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
B

Bradley1234

VB to CS converter?? HUH? What is this thing you speak of?

When I added the ArrayList c = new ArrayList();

My CS gave me a line under the first A, adding a choice of 2 possible items,
I picked

System.Collections.ArrayList c = new ArrayList(); //C# is awesome



But since when does VB.net use the dim x AS ? Thats VB2-6 isnt it?
 
J

Jimi

It's a product called Instant C# which converts VB.NET code to C#
(www.instantcsharp.com).

"Dim x as..." is still standard VB for variables declared in methods.
You can even still code this way for class declarations I think.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
B

Bob Grommes

No, VB.NET also uses the Dim someVariable As SomeType [= someValue] syntax.

--Bob
 

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