VB.NET to c# convert

  • Thread starter Thread starter Michael Nicol
  • Start date Start date
M

Michael Nicol

Hey all

Our company recently started using .net and started in VB.NET. We've since
changed to c#, but has some code already written in VB.NET. I'm looking for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?
 
There are none that are perfected. The best option is convert and fix.

One of the issues is there are training wheels available for VB.NET that are
not present in C#. While most of the converters do great translating VB.NET
to C#, when both are using .NET classes, the VB shortcuts often blow the
translation up. The more your team has used the VB functions, etc., the less
likely you have a clean translation. Most of the translator writers I have
conversed with are C# developers, so you can see the bias. ;-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
Thanks...

Figured as much... Oh the joys / legacy of VB and the allowance of things
that just shouldn't be... ;)
 
Ya know what, I found that the conveters I used mostly work ok, they seem to
have trouble converting event handlers back into the delegate declaration
required by C#. Ive done a lot of translation both ways, and I find VB to C#
dead easy most of the time, but the other way is normally a bit of a pain.

Its a case of hacking it till it works Im afraid.




--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
Michael,

I am just curious, since it is in VB.NET, why not leave compiled
assemblies as they are, and then just make sure all new development is done
in C#? All you have to do is add an assembly reference, and it works.

This way, you don't have to spend resources on something that is really
just a preference, and not a need (you gain almost nothing by changing the
code to C#).
 
exactly. Whole point of the framework.
Otherwise what happens if your company changes it's mind again and goes for
C++.net or Python.net!


Nicholas Paldino said:
Michael,

I am just curious, since it is in VB.NET, why not leave compiled
assemblies as they are, and then just make sure all new development is done
in C#? All you have to do is add an assembly reference, and it works.

This way, you don't have to spend resources on something that is really
just a preference, and not a need (you gain almost nothing by changing the
code to C#).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Michael Nicol said:
Thanks...

Figured as much... Oh the joys / legacy of VB and the allowance of things
that just shouldn't be... ;)



"Cowboy (Gregory A. Beamer) [MVP]" <[email protected]>
wrote
in message news:%[email protected]... that
are nice
c#. wondering
if good
by
 
Thats fine provided you are able to leave the compiled assemblies compiled,
if you need to maintaine them, this then becomes more of an issue.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

Nicholas Paldino said:
Michael,

I am just curious, since it is in VB.NET, why not leave compiled
assemblies as they are, and then just make sure all new development is done
in C#? All you have to do is add an assembly reference, and it works.

This way, you don't have to spend resources on something that is really
just a preference, and not a need (you gain almost nothing by changing the
code to C#).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Michael Nicol said:
Thanks...

Figured as much... Oh the joys / legacy of VB and the allowance of things
that just shouldn't be... ;)



"Cowboy (Gregory A. Beamer) [MVP]" <[email protected]>
wrote
in message news:%[email protected]... that
are nice
c#. wondering
if good
by
 
* "Michael Nicol said:
Our company recently started using .net and started in VB.NET. We've since
changed to c#, but has some code already written in VB.NET. I'm looking for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?

I don't know a good converter for this purpose, but why don't simply
leave the code in VB.NET? This would save a lot of work and would not
have any disadvantages.
 
I don't know a good converter for this purpose, but why don't simply
leave the code in VB.NET? This would save a lot of work and would not
have any disadvantages.

Read the message from OHM, I find that a good point.

And as Rakesh said, after too much C# it's always a bit of a chore to think
in
vb.net :)

Cor
 
Michael Nicolwrote:
Hey all
Our company recently started using .net and started in VB.NET. We've since
changed to c#, but has some code already written in VB.NET. I'm looking for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?

Try the Demo Edition of our Instant C# converter and let us know if
you find any "strange stuff" produced by it. I think you'll be
pleasantly surprised.
 
OK then, tell me how you would create a Unsigned Int in VB.NET, which you
can do in C#

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
I was wondering if you could do that, I needed it for a project... My
question is answered now =S

Andre Nogueira
 
Link?

David Anton said:
Try the Demo Edition of our Instant C# converter and let us know if
you find any "strange stuff" produced by it. I think you'll be
pleasantly surprised.
 
OK then, tell me how you would create a Unsigned Int in VB.NET, which you
can do in C#

Option Strict On

Imports System

Class Test

Shared Sub Main
Dim x as UInt32 = Convert.ToUInt32(0)
End Sub

End Class

There's not a lot you can do with it once you've created it,
admittedly, but you can create it...
 
I realise this, I was making a point about language differences for the
benefit of the poster above me.

Cheers

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
* "One Handed Man \( OHM - Terry Burns \) said:
OK then, tell me how you would create a Unsigned Int in VB.NET, which you
can do in C#

Unsigned integer datatypes are /not/ CLS compliant and should not be
used if not necessary. VB 2005 will provide full support for unsigned
types, but they will still remain not CLS compliant.
 
Could you compile what you have and then use anakrino or similar to
decompile into c# source?
 
I can see a reasoning in maintainability. If your company standardizes on
C#, you do not necessarily want to cross-train devs in VB.NET. I have no
problem in either language, but I can see good reasons to standardize, esp.
for smaller companies without many devs.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
Nicholas Paldino said:
Michael,

I am just curious, since it is in VB.NET, why not leave compiled
assemblies as they are, and then just make sure all new development is done
in C#? All you have to do is add an assembly reference, and it works.

This way, you don't have to spend resources on something that is really
just a preference, and not a need (you gain almost nothing by changing the
code to C#).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Michael Nicol said:
Thanks...

Figured as much... Oh the joys / legacy of VB and the allowance of things
that just shouldn't be... ;)



"Cowboy (Gregory A. Beamer) [MVP]" <[email protected]>
wrote
in message news:%[email protected]... that
are nice
c#. wondering
if good
by
 
I think the issue is the devs of the original used the "training wheels"
inherent in VB, which means the C# program, once decompiled, would have
references back to Microsoft.VisualBasic and
Microsoft.VisualBasic.Compatibility, adding weight that need not be there.
Decompilation is a good start.

If I were doing it this way, I would decompile and remove all VB reference
statements and fix all the explosions. It is an option. Salamander
decompiler is even sweeter, but a bit pricey for some shops.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
Back
Top