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

选择 VB.NET 还是 C#?

作者:闵涛 文章来源:闵涛的学习笔记 点击数:1015 更新时间:2009/4/23 19:00:58

选择 VB.NET 还是 C#?


面向对象的编程方法在.NET的世界里已经是大势所趋,你选择VB.NET还是C#??

With VB.NET, Microsoft has given Visual Basic programmers all the things we''''ve been asking for over the years, namely a true object-oriented programming language. You may be hearing the buzz that VB.NET is so different you won''''t even recognize it. Sure, they had to remove some minor things in the language, and change some of the objects, properties, and methods, but this shouldn''''t be a big deal to most Visual Basic programmers. In fact, I think after you start to use it regularly, you''''ll find it''''s simpler and more intuitive than previous versions of Visual Basic. Because there will be a learning curve with Visual Basic.NET, you might be curious about C# and wondering if you should give up Visual Basic altogether.

If you are currently a Visual Basic programmer, and especially if you have been for years, you won''''t need to switch to another language like C# or Delphi. You''''ll find the core language of Visual Basic is still the same, although there are some minor differences. The majority of the changes are in the objects, properties, and methods you use in VB.NET. You have to learn these new things no matter which .NET language you choose to use.

Now, if you''''ve been using BASIC since the old DOS days, then you''''re in for a shock, as they have removed GoSub, While/Wend, Let a=b, and a host of other obsolete commands. But Microsoft has been warning you not to use these unstructured statements anyway.

Advantages of VB.NET

VB.NET has features that C# doesn''''t. For example, the IsDBNull() function is in VB.NET, but not in C#. VB.NET has exponentiation and can re-allocate arrays using Redim; these aren''''t available in C#. C# is case-sensitive for keywords and variables. Most Visual Basic programmers aren''''t used to this, and this can cause lost time unless you''''re really consistent in your typing. Personally, I like Visual Basic''''s use of If. . .End If and Do. . .Loop as opposed to C#''''s use of curly braces. I find it hard to keep track of these braces. Select Case statements are easier and more compact than in C#. In C#, you have to use the break statement all the time to break out of the select structure. In Visual Basic, you can use Case 1 to 50: In C#, you have to code 50 individual case statements for this.

When you''''re using the OOP features of Visual Basic, you''''ll find keywords words like Inherits, MustInherit, NotInheritable, Overridable, and so on. In C#, these same features involve more cryptic words and syntax. For example, to inherit a base class in VB.NET, you would write something like this:

Public Class Person
  ...
End Class
Public Class Employee
  Inherits Person
  ...
End Class

Here''''s the same code in C#:

public class Person
{
  public Person() {    
     ...
  }
}
public class Employee : Person
{
    public Employee() {
     ...
    }
}

If you don''''t look closely, you may miss the fact that the Employee class in the C# version is inherited from the Person class (denoted by the Employee : Person syntax).

How bad will the upgrade process be?

The migration from Visual Basic 6.0 to VB.NET won''''t be without challenge, but there are some things you can do now to prepare. First, use classes, COM components, and n-tier development techniques. If you use these programming constructs, you''''ll have the easiest migration path since these convert to .NET. There are some programming styles that won''''t migrate so easily -- for example, non-zero-based arrays, implicit variables (not using Option Explicit), and Jet or RDO. You''''ll have to do some significant rewriting to port these types of applications.

There is nothing wrong with keeping your existing applications in Visual Basic 6.0 and just doing new development in VB.NET. The two will co-exist on one machine just fine. In fact, this will probably be a common approach.

Introducing C#

Microsoft had a couple of goals in mind when they created C#. First, they needed an alternative to Java. With their constant court battles over this language, and most people viewing Java as a Sun product, Microsoft needed their own language that was similar to Java, but distinctly their own. In addition, Microsoft wanted a new, clean language that didn''''t have any legacy code that users still needed to maintain. The result is a clean language, without a lot of baggage.

The people who will most likely use the C# language will be Java, C, and C++ developers. These programmers will already be familiar with the language constructs and the case sensitivity. They''''ll also have the learning curve of the .NET classes to deal with, so they don''''t have much of an advantage over Visual Basic developers.

Advantages of C#

I am admittedly a Visual Basic proponent, but C# does have some advantages. For example, the ability to have multi-line comments without having to repeat the comment character is pretty slick. C# can also do pre- and post-incrementing and decrementing, for example:

intValue--
intValue-

The first line in the above code increments the variable intValue by one. The second line decrements the variable by one. This is a nice shorthand compared to the more lengthy Visual Basic version of intValue += 1.

Another benefit of C# is that there are currently more sample programs in the beta version than there are samples in VB.NET. This will likely change in a future release.

Although not often used for business applications, C# lets you have pointers. While pointers can lead to many problems, there may be times when you need them. In this instance, C# has a slight advantage over Visual Basic. However, in my programming, I rarely need pointers.

C# has the ability to use the Unsigned data types defined in the .NET runtime. Again, the need for this in a business application isn''''t common, but it is an area where C# has more access to the .NET runtime engine than VB.NET.

The migration road

The road from Visual Basic 6.0 to VB.NET won''''t be easy, but I think it will be well worth the investment in time for you to learn this new language. In the meantime, I recommend you start learning OOP-style programming. You''''re definitely going to need it for programming in the .NET world. Whichever language you choose, you''''ll find the .NET platform is excellent for creating desktop, Internet, intranet, and distributed applications.


[精彩网文]俞敏洪:不同的选择,不同的生活  [精彩网文]经典励志故事:无数的选择操之在我
[精彩网文]励志小故事:选择,是人生成功最重要的因素  [精彩网文]选择北京大学的十大理由(鼓舞人心)
[办公软件]快速选择Excel工作表  [Web开发]选择重复记录
[Web开发]C#排序算法:冒泡排序、选择排序、插入排序、希尔…  [Web开发]如何给动态的或静态的CheckBoxList多选钮添加选择…
[Web开发]Asp.net中实现从弹出窗口中选择值—弹出模态窗口  [Web开发]asp.net c#常用语句之选择分支语句if、switch实例…
教程录入: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……
    咸宁网络警察报警平台