简体   繁体   中英

Converting “myself” from C# to VB.NET

I am a C# programmer (hobby), but I want to convert to a VB.NET programmer. I have seen many posts written in both C# and VB.NET, but I need some links which explain from the basics (like void main void) to the most advanced.

Note: Microsoft blogs (until now whatever I read) do not refer to the basic core level knowledge/things .

Aside from books/blogs, a good way to learn the other side of the C#/VB wall is to write some code in C#, compile it, and open the DLL in Reflector and view as VB code. This will allow you to answer your own questions about VB.NET.

For example, suppose you want to see how to do generics in VB.NET. You write a simple library in C#:

void SomeMethod()
{
    List<int> list = new List<int>();
}

Compile this, then open in Reflector, and it will show you:

Sub SomeMethod
    Dim list as List(Of Integer) = New List(Of Integer)
End Sub

or something like that...

If you know how to do it in C#, you can probably teach yourself how to do it in VB.NET this way easier than looking for samples online.

C# and VB.NET are just syntactic sugar on top of the .NET Framework. .NET Framework APIs are the same for both, and there are some features which are available to one and not to the other.

One thing you will find yourself is putting ";" after every statement when you switch from C# to VB.NET (which is illegal in VB.NET).

The thing about Visual Basic .NET is that it has a huge history in pre-.NET versions. This has caused some odd constructions and keywords that are not entirely logical from a C# point of view but do make sense when you have a background in VB.

Eg, And, AndAlso, Or, OrElse. Look them up and find out that it is all about keeping the VB6 programmers happy.

Get a good book if you really want/need to do this. This is bigger than a single question on this forum.

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

You might also be interested in the questions " what's allowed in VB that is prohibited in C# " and " Converting C# knowledge to VB.Net "

MS blog wouldn't talk about basic stuff, unless they're something newly released or in progress. I suggests the MSDN instead http://msdn.microsoft.com/en-us/library/2x7h1hfk.aspx

我找到了代码项目文章VB.NET和C#的完全比较,它对VB语言版本2005的VB.NET和C#进行了深入比较。我希望这会有所帮助。

Might I also recommend the VB Language Spec

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM