转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
VB .NET vs. C#         ★★★★

VB .NET vs. C#

作者:闵涛 文章来源:闵涛的学习笔记 点击数:2351 更新时间:2009/4/23 16:37:58
same thing.

 

The difference between the functionality of VB .NET and C# is even smaller. If you create a new project in Visual Studio .NET, you see the exact same project types listed for each language. So, if the project types are the same, and the functionality differences between the languages are small, does it matter which you choose?

 

If the answer was no, this would be a short article. The fact is that the language you choose probably won’t hinge on the functionality in the language itself. Instead, your choice will hinge on some other criteria, which we’ll examine in a moment.

  看一下细节的东西吧!

What about Speed?

速度的问题呢?

Unfortunately, it’s too early to tell about speed. According to Microsoft, the speed between the two languages will be the same. Much of your code actually will be calling classes in the CLR, so that will be the same regardless of the language used to call it. As for the speed of items such as loops and string concatenation, that will depend on the compiler.

 

Microsoft officials say VB .NET and C# will compile to the same IL, so the result will be the same speed. I must admit I’m skeptical, but there is no way to test this at this time. With .NET still in beta (.NET was not yet final when this article went to press. - Ed.), any speed tests most likely would bear little resemblance to the final product. For now, assume the speed will be very close, and don’t worry about it until .NET is a finished product.

       看来速度还是差不多,播种之间。

 

What about Language Differences?

The differences in the languages are small, but they do exist. For example, C# allows you to have unsigned integers of various sizes, and VB .NET does not. It is important to note, however, that unsigned integers are not part of the Common Language Specification (CLS), a part of the .NET Framework that defines what language elements can be used to allow inheritance between languages. If cross-language inheritance is something you want to ensure, you need to stick to only CLS-compliant types for any exposed parameters and return values.

  小细节:C#拥有无符号整数、VB.NET没有。但是无符号数不符合CLS规范,不利于跨语言继承。还是建议不要用无符号数。

VB .NET adds some of the C/C++ shortcuts, such as +=, -=, and others. Now, in VB .NET, x += 5 is the same as x = x + 5. However, VB .NET does not support the ++ or -- operators, which C/C++ programmers frequently use. C# supports all of these, of course. C# also supports the concept of operator overloading, in which a developer can overload operators such as +, - , and True. Operator overloading is admittedly not something most VB .NET developers will miss, but it is one of the differences between the two languages.

  VB.NET增加了一些C++的特性,比如+=,-=.但是C#全面保留了原来C++的这姓特性,比如++ ,――,这些还不是很重要的。VB.NET不具有运算符重载,这倒是两个语言的一个小区别。

I won’t go into the differences in the actual syntax here, except for two items that are only relevant to VB developers thinking of making the switch to C#: case sensitivity and the equality operator. (See Eric Smith’s article There and Back Again for more on syntactical differences and how to move code from one language to another.) Don’t forget that VB and VB .NET are not case sensitive, while C# is. Also, the assignment operator in C# is the equal sign (=) but the equality operator is the double equal sign (==). These two differences are a major headache for VB developers trying to make the switch to C#.

  VbVB.NET都是大小写不分的,C#是区别的。还有,两者是不是相等,C#还是两个等号。

To see some of the general language differences, check out the sample VB .NET code in FIGURE 1.

  两个具体的例子:

Module Module1

 

   Sub Main()

      Dim x As Integer = 5

      Console.WriteLine("The secret number is: " & x)

   End Sub

 

End Module

FIGURE 1: Sample VB .NET code.

 

As you can see, VB .NET now allows you to initialize variable values at declaration. The next line uses the WriteLine method of the Console class. There is some simple string concatenation, and the string is printed to the console (or the DOS window or command window).

 

FIGURE 2 shows the same application written in C#. The variable declaration is cleaner, but the Console.WriteLine is almost identical. Notice the curly braces and semicolons in the C# program, which are familiar to C/C++ and Java developers.

 

using System;

 

namespace ConsoleApplication3

{

  class Class1

  {

    static void Main(string[] args)

    {

      int x=5;

      Console.WriteLine("The secret number is: " + x);

    }

  }

}

FIGURE 2: The same application as in FIGURE 1, but written

上一页  [1] [2] [3] [4]  下一页


[VB.NET程序]GSM短信模块库函数,可以用VB,VC,调用简单实用  [C语言系列][C#防止反编译].NET 产品版权保护方案 (.NET源码加…
[互联动态].NETFramework3.0新特性介绍与问答翻译  [Web开发]asp.net代码空格显示为……点号的原因及解决办法
[Web开发]asp.net调用压缩软件对文件进行压缩与解压缩的代码  [Web开发]详细介绍asp.net获取日期时间的各种格式的函数
[Web开发]如何将JS文件编译到ASP.NET项目里的DLL文件中  [Web开发]asp.net加密口令的最简单方法
[Web开发]目前asp.net开发主流工具软件介绍  [Web开发]asp.net中的反射介绍
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台