NewGuy
NewGuy

Reputation:

Transitioning from C# to VB.NET

Any suggestions on how I should approach this? Thanks.

Upvotes: 5

Views: 571

Answers (13)

MarkJ
MarkJ

Reputation: 30398

There were some useful articles in Visual Studio magazine back in Jan 2008.

Upvotes: 0

Martin Liversage
Martin Liversage

Reputation: 106826

Use XML literals and marvel how resentful fellow C# programmers suddenly are.

Upvotes: 0

TGnat
TGnat

Reputation: 4001

You can also use a tool like CodeRush from DevExpress (no affiliation). The short-cut keys for any operation are the same for both languages and will produce the correct output for the language.

For example: key combo "mv" yields:

In C#

public void MethodName ()
{

}

In VB

Public Sub MethodName()

End Sub

Upvotes: 0

Jage
Jage

Reputation: 565

Take advantage of the "With" statement! One of my favorite parts of VB.NET.

Upvotes: 2

Scott Ivey
Scott Ivey

Reputation: 41558

I have to do this often - and my biggest hang-up is the semi-colon. Never fails that my first few days of writing VB after a longer stint of C# coding, the VB compiler is always barking at me for putting a semi-colon on every line of VB code.

Other than that, it shouldn't be too painful. If you're fluent in C#, moving to VB might be stressful for the first few days, but after that you should be smooth sailing.

Code converter tools come in handy to help you remember/learn/re-learn all of those odd syntax differences that you forget easily. The one I normally turn to first is http://converter.telerik.com/ - and if that won't do the trick, a quick google search for code converters will turn up a handful of other good ones.

Another pain point that I've had in the past too is Snippets. Snippets in C# rock - but in VB rock a bit less. Get to know the differences between those and life will be much easier. (Come on VB team - get that enter key working like the C# snippet team has it...)

Upvotes: 3

Greg D
Greg D

Reputation: 44066

It's a pretty straight-forward thing, actually. VB.Net is a perfectly good (if, imo, verbose) language with most of the expressiveness you've grown accustomed to in C#. Just be aware that certain specific keywords are different and that you've got a different background culture and you'll do fine.

Upvotes: 0

aarthir
aarthir

Reputation:

My first question would be 'Why?'. I'd like to think that you can pretty much get the same thing done with either C# or VB.Net. Given that it's managed code, why not just leave them as they are?

Let's just assume you have your reasons :)

1) There are a couple of tools that will do this (see http://www.developerfusion.com/tools/convert/csharp-to-vb/ for a sample).
2) The other option is to manually convert the code, compile, fix errors, and repeat. Painful.

Upvotes: 0

zvikara
zvikara

Reputation: 1647

A good C# to VB.NET converter will help.

Upvotes: 3

Daniel
Daniel

Reputation: 22395

If you are familiar with programing you should just have to learn the syntax...why would anyone want to go from C# to VB? who knows :)

Upvotes: 0

VinPepe
VinPepe

Reputation: 561

It's not as difficult as it seems at first. Took me about a month from going strictly C++\C# to VB to get comfortable.

Upvotes: 0

Abel Gaxiola
Abel Gaxiola

Reputation: 402

I went the other way (VB to C#) and found the syntax to be so similar that the transition was painless. I can now pretty much program in either platform – thanks a lot to the IDE intellisense.

Upvotes: 2

William Edmondson
William Edmondson

Reputation: 3637

Aside from revulsion and horror I recommend (from experience - ugh) to just start. Build a simple app. The magic is in the experience. It doesn't make sense until you have spent lots of time trying to figure out why something doesn't work.

Upvotes: 2

Matthew Groves
Matthew Groves

Reputation: 26141

Take a look at this VB to C# Comparison chart for some of the syntax and keyword differences.

Upvotes: 4

Related Questions