milani_lucie
asked on
Convert from C# to VB.NET - Framework 3.5
Hi,
Can you please provide me equivalent code in VB.NET which is working ?
var y = new[] { 123, 236, 389 };
Console.WriteLine(y[0]);
Console.WriteLine(y[1]);
Console.WriteLine(y[2]);
Console.WriteLine(y.GetTyp e().Name);
Thanks
Can you please provide me equivalent code in VB.NET which is working ?
var y = new[] { 123, 236, 389 };
Console.WriteLine(y[0]);
Console.WriteLine(y[1]);
Console.WriteLine(y[2]);
Console.WriteLine(y.GetTyp
Thanks
ASKER
What is this declaration ?
Dim y As var = New () {123, 236, 389}
This must be
Dim y = New () {123, 236, 389} --- This is not correct (Error)
Thanks
Dim y As var = New () {123, 236, 389}
This must be
Dim y = New () {123, 236, 389} --- This is not correct (Error)
Thanks
Almatrodi - if that's the code returned by the converter, you may want to try a different one, because it is wrong.
The VB.Net version is this...
Dim y = New Object() {123, 236, 389}
Console.WriteLine(y(0))
Console.WriteLine(y(1))
Console.WriteLine(y(2))
Console.WriteLine(y.GetTyp e().Name)
Wayne
The VB.Net version is this...
Dim y = New Object() {123, 236, 389}
Console.WriteLine(y(0))
Console.WriteLine(y(1))
Console.WriteLine(y(2))
Console.WriteLine(y.GetTyp
Wayne
ASKER
Wayne,
Console.WriteLine(y.[GetTy pe]().Name )
returns "Int32[]" in C#
Console.WriteLine(y.GetTyp e().Name)
returns "Object[]" in VB.NET
I think so there is some thing wrong !
Thanks
Console.WriteLine(y.[GetTy
returns "Int32[]" in C#
Console.WriteLine(y.GetTyp
returns "Object[]" in VB.NET
I think so there is some thing wrong !
Thanks
Just change it to
Dim y = New Integer() { 123, 236, 389 }
Dim y = New Integer() { 123, 236, 389 }
Declaring an variable as 'var' in C# informs the compiler to determine the object type. VB.Net doesn't have an equivelent, so I explicitely used Object, but Almatrodi is correct - simply replace 'Object' with 'Integer'.
Wayne
Wayne
you can always use this site to convert from VB.NET to C# and vice-versa.
http://www.carlosag.net/Tools/CodeTranslator/
http://www.carlosag.net/Tools/CodeTranslator/
dnwx - did you try it? You'll find that that converter fails to convert it properly also.
Wayne
Wayne
Webtubbs, I didn't really try it since I always use it.
Well, I'm sorry if it didn't work, but at least there's a tip for future needs.
Well, I'm sorry if it didn't work, but at least there's a tip for future needs.
How about
Dim y = New(){123, 236, 389}
Dim y = New(){123, 236, 389}
ASKER
CodeCruiser:
How about
Dim y = New(){123, 236, 389}
This does NOT work. Any pointers ?
Thanks
How about
Dim y = New(){123, 236, 389}
This does NOT work. Any pointers ?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Console.WriteLine(y(0))
Console.WriteLine(y(1))
Console.WriteLine(y(2))
Console.WriteLine(y.[GetTy