从C#过渡到VB.NET

时间:2022-08-08 13:56:04

Any suggestions on how I should approach this? Thanks.

关于我应该如何处理的任何建议?谢谢。

13 个解决方案

#1


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.

我必须经常这样做 - 而我最大的问题就是分号。经过长时间的C#编码后,我编写VB的前几天从未失败过,VB编译器总是咆哮着我在VB代码的每一行都放了一个分号。

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.

除此之外,它不应该太痛苦。如果你能熟练使用C#,那么在最初的几天内转向VB可能会有压力,但在此之后你应该顺利航行。

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.

代码转换器工具可以帮助您记住/学习/重新学习您容易忘记的所有奇怪的语法差异。我通常转向的第一个是http://converter.telerik.com/ - 如果这不起作用,快速谷歌搜索代码转换器将出现一些其他好的。

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...)

我过去的另一个痛点是Snippets。 C#摇滚中的片段 - 但在VB摇滚中少了一些。了解这些与生活之间的差异会更容易。 (加入VB团队 - 让C#片段团队得到那个输入密钥的工作......)

#2


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

看看这个VB到C#的比较图表,了解一些语法和关键字的差异。

#3


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

一个好的C#到VB.NET转换器会有所帮助。

#4


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.

除了反感和恐怖,我建议(从经验 - 呃)刚开始。构建一个简单的应用程神奇之处在于体验。直到你花了很多时间试图弄清楚为什么某些东西不起作用,它才有意义。

#5


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.

我走了另一条路(VB到C#),发现语法非常相似,转换是无痛的。我现在几乎可以在任一平台上编程 - 非常感谢IDE intellisense。

#6


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

利用“With”声明!我最喜欢的VB.NET部分之一。

#7


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.

它并不像最初看起来那么困难。花了大约一个月的时间从严格的C ++ \ C#到VB来舒服。

#8


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 :)

如果你熟悉编程,你只需要学习语法......为什么有人想从C#转到VB?谁知道 :)

#9


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?

我的第一个问题是'为什么?'。我想你可以用C#或VB.Net完成同样的事情。鉴于它是托管代码,为什么不直接保留它们?

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.

1)有几种工具可以做到这一点(参见http://www.developerfusion.com/tools/convert/csharp-to-vb/获取样本)。 2)另一种选择是手动转换代码,编译,修复错误和重复。痛苦。

#10


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.

实际上,这是一个非常直截了当的事情。 VB.Net是一种非常好的(if,imo,verbose)语言,具有你在C#中习惯使用的大部分表现力。请注意,某些特定的关键字是不同的,并且您拥有不同的背景文化,并且您会做得很好。

#11


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.

您还可以使用DevExpress的CodeRush等工具(无联属关系)。任何操作的快捷键对于两种语言都是相同的,并且将为语言生成正确的输出。

For example: key combo "mv" yields:

例如:键组合“mv”产生:

In C#

public void MethodName ()
{

}

In VB

Public Sub MethodName()

End Sub

#12


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

使用XML文字,并惊叹于C#程序员的不满情绪。

#13


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

2008年1月,Visual Studio杂志上有一些有用的文章。

#1


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.

我必须经常这样做 - 而我最大的问题就是分号。经过长时间的C#编码后,我编写VB的前几天从未失败过,VB编译器总是咆哮着我在VB代码的每一行都放了一个分号。

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.

除此之外,它不应该太痛苦。如果你能熟练使用C#,那么在最初的几天内转向VB可能会有压力,但在此之后你应该顺利航行。

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.

代码转换器工具可以帮助您记住/学习/重新学习您容易忘记的所有奇怪的语法差异。我通常转向的第一个是http://converter.telerik.com/ - 如果这不起作用,快速谷歌搜索代码转换器将出现一些其他好的。

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...)

我过去的另一个痛点是Snippets。 C#摇滚中的片段 - 但在VB摇滚中少了一些。了解这些与生活之间的差异会更容易。 (加入VB团队 - 让C#片段团队得到那个输入密钥的工作......)

#2


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

看看这个VB到C#的比较图表,了解一些语法和关键字的差异。

#3


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

一个好的C#到VB.NET转换器会有所帮助。

#4


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.

除了反感和恐怖,我建议(从经验 - 呃)刚开始。构建一个简单的应用程神奇之处在于体验。直到你花了很多时间试图弄清楚为什么某些东西不起作用,它才有意义。

#5


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.

我走了另一条路(VB到C#),发现语法非常相似,转换是无痛的。我现在几乎可以在任一平台上编程 - 非常感谢IDE intellisense。

#6


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

利用“With”声明!我最喜欢的VB.NET部分之一。

#7


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.

它并不像最初看起来那么困难。花了大约一个月的时间从严格的C ++ \ C#到VB来舒服。

#8


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 :)

如果你熟悉编程,你只需要学习语法......为什么有人想从C#转到VB?谁知道 :)

#9


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?

我的第一个问题是'为什么?'。我想你可以用C#或VB.Net完成同样的事情。鉴于它是托管代码,为什么不直接保留它们?

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.

1)有几种工具可以做到这一点(参见http://www.developerfusion.com/tools/convert/csharp-to-vb/获取样本)。 2)另一种选择是手动转换代码,编译,修复错误和重复。痛苦。

#10


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.

实际上,这是一个非常直截了当的事情。 VB.Net是一种非常好的(if,imo,verbose)语言,具有你在C#中习惯使用的大部分表现力。请注意,某些特定的关键字是不同的,并且您拥有不同的背景文化,并且您会做得很好。

#11


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.

您还可以使用DevExpress的CodeRush等工具(无联属关系)。任何操作的快捷键对于两种语言都是相同的,并且将为语言生成正确的输出。

For example: key combo "mv" yields:

例如:键组合“mv”产生:

In C#

public void MethodName ()
{

}

In VB

Public Sub MethodName()

End Sub

#12


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

使用XML文字,并惊叹于C#程序员的不满情绪。

#13


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

2008年1月,Visual Studio杂志上有一些有用的文章。