C#.net 和 Visual Basic.net 之间有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/523722/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 06:42:45  来源:igfitidea点击:

What are the differences between C#.net and Visual Basic.net?

c#.netvb.netprogramming-languages

提问by Niyaz

I have a small experience in VB.net and I would like to learn C#.net

我对VB.net有一点小经验,想学习C#.net

What are the differences between VB.net and C#.net?

VB.net 和 C#.net 有什么区别?

Is there any difference in performance between these two?

这两者在性能上有什么区别吗?

Apart from the syntactical differences, are there any major changes that I have to keep in mind?

除了语法上的差异之外,还有什么我必须记住的重大变化吗?

采纳答案by Noldorin

The Language Featuressection of the Wikipediaarticle offers a good overview. Performance is essentially equivalent in almost every aspect, from what I understand.

维基百科文章的语言特性部分提供了一个很好的概述。据我了解,性能几乎在每个方面都基本相同。

回答by Bruno Costa

I think you will find the answers to your question in this articles:

我想你会在这篇文章中找到你问题的答案:

http://en.wikipedia.org/wiki/Comparison_of_C_sharp_and_Visual_Basic_.NET

http://en.wikipedia.org/wiki/Comparison_of_C_sharp_and_Visual_Basic_.NET

and

http://geekswithblogs.net/jmccarthy/archive/2007/01/23/104372.aspx

http://geekswithblogs.net/jmccarthy/archive/2007/01/23/104372.aspx

edit: Noldorin was faster :x

编辑:诺多林更快:x

回答by Nick Berardi

The first thing to know about learning C# is that it is not pronounced "C#.net", it is just C#. Microsoft tacked on ".NET" to VB, because there was a previous version of VB that didn't work on the .NET Framework. C# was created specifically with the .NET Framework in mind, so the ".net" is implied and unnecessary. Also as a side note putting "C#.NET" on your resume really tips off a knowledgeable manager to your skill level, or lack there of, regarding C#.

学习 C# 的第一件事是它不发音为“C#.net”,它只是 C#。Microsoft 将“.NET”附加到 VB,因为 VB 的先前版本无法在 .NET Framework 上运行。C# 是专门针对 .NET Framework 创建的,因此“.net”是隐含的且不必要的。另外,在简历上写上“C#.NET”的旁注真的可以让知识渊博的经理了解你的技能水平,或者缺乏关于 C# 的技能。

Also this Wikipedia articleis really good for showing the pros and cons as well as the differences between C# and VB.NET at a high level.

此外,这篇 Wikipedia 文章非常适合在高层次上展示 C# 和 VB.NET 之间的优缺点以及差异。

回答by Sachin Chavan

Follow following links which give detailed differences

按照以下提供详细差异的链接

http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

http://www.codeproject.com/KB/dotnet/vbnet_c__difference.aspx

http://www.codeproject.com/KB/dotnet/vbnet_c__difference.aspx

http://support.microsoft.com/kb/308470

http://support.microsoft.com/kb/308470

In spite of differences as mentioned at http://support.microsoft.com/kb/308470both C# and VB.Net are first class citizens of .Net world

尽管在http://support.microsoft.com/kb/308470 中提到了差异,但 C# 和 VB.Net 都是 .Net 世界的一等公民

Although there are differences between Visual Basic .NET and Visual C# .NET, both are first-class programming languages that are based on the Microsoft .NET Framework, and they are equally powerful. Visual Basic .NET is a true object-oriented programming language that includes new and improved features such as inheritance, polymorphism, interfaces, and overloading. Both Visual Basic .NET and Visual C# .NET use the common language runtime. There are almost no performance issues between Visual Basic .NET and Visual C# .NET. Visual C# .NET may have a few more "power" features such as handling unmanaged code, and Visual Basic .NET may be skewed a little toward ease of use by providing features such as late binding. However, the differences between Visual Basic .NET and Visual C# .NET are very small compared to what they were in earlier versions.

尽管 Visual Basic .NET 和 Visual C# .NET 之间存在差异,但两者都是基于 Microsoft .NET Framework 的一流编程语言,并且功能同样强大。Visual Basic .NET 是一种真正的面向对象的编程语言,包括新的和改进的功能,例如继承、多态、接口和重载。Visual Basic .NET 和 Visual C# .NET 都使用公共语言运行时。Visual Basic .NET 和 Visual C# .NET 之间几乎没有性能问题。Visual C# .NET 可能有一些更“强大”的功能,例如处理非托管代码,而 Visual Basic .NET 可能会通过提供诸如后期绑定等功能来稍微倾向于易用性。但是,Visual Basic .NET 和 Visual C# 之间的差异。

回答by Dave Markle

Performance is equivalent if you write equivalent code, but VB.NET has constructs that are in there for "backward compatibility" which should NEVER be used. C# doesn't have some of these things. I'm thinking specifically of:

如果您编写等效的代码,则性能是等​​效的,但 VB.NET 具有用于“向后兼容”的结构,永远不应使用。C# 没有这些东西。我特别在想:

  • Functions which are in the Microsoft.VisualBasic namespace which are members of other standard .NET classes like Trim(). The .NET classes are often faster.

  • Redim and Redim Preserve. Never to be used in .NET, but there they are in VB.

  • On Error ... instead of exceptions. Yuck!

  • Late binding (sometimes derisively called "Option Slow"). Not a good idea in a non-dynamic .NET language from a performance perspective.

  • Microsoft.VisualBasic 命名空间中的函数,它们是其他标准 .NET 类(如 Trim())的成员。.NET 类通常更快。

  • Redim 和 Redim 保护区。永远不会在 .NET 中使用,但它们在 VB 中。

  • On Error ... 而不是异常。糟糕!

  • 后期绑定(有时被戏称为“Option Slow”)。从性能角度来看,在非动态 .NET 语言中这不是一个好主意。

VB is also missing things like automatic properties which makes it pretty undesirable for me. Not a performance issue, but worth keeping in mind.

VB 还缺少诸如自动属性之类的东西,这对我来说非常不受欢迎。不是性能问题,但值得牢记。

回答by Damith

No matter which language you select based on your personal preference and past experience, both languages are powerful developer tools and first-class programming languages that share the common language runtime in the .NET Framework.

无论您根据个人喜好和过去的经验选择哪种语言,这两种语言都是强大的开发人员工具和一流的编程语言,它们共享 .NET Framework 中的公共语言运行时。

Says by Microsoft https://web.archive.org/web/20061027230435/http://support.microsoft.com/kb/308470

微软说 https://web.archive.org/web/20061027230435/http://support.microsoft.com/kb/308470