C#的优势在VB [英] C#'s edge over VB

查看:147
本文介绍了C#的优势在VB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么用C#.NET使它更适合对某些项目比VB.NET?

What in C#.NET makes it more suitable for some projects than VB.NET?

业绩?能力?库/组件?声誉?可靠性?可维护性?,放心?

Performance?, Capabilities?, Libraries/Components?, Reputation?, Reliability? Maintainability?, Ease?


基本上任何 C#可以做的,这是不可能的使用VB,或反之亦然。 事情你不得不考虑当选择C#/ VB的一个项目。

Basically anything C# can do, that is impossible using VB, or vice versa. Things you just have to consider when choosing C#/VB for a project.

推荐答案

C#和VB基本上是相同的但有一些细微的差别。除了明显的语法差异有以下区别:

C# and VB are basically the same however there are some minor differences. Aside from the obvious grammar differences you have the following differences:

  1. 在C#中可以调用不安全code
  2. VB有可选的参数(即将在C#4.0)
  3. VB是比较容易做后期绑定调用时使用(即将在C#4.0),这和一些做2化妆用VB做办公自动化干净多了。
  4. 在VB中有一堆的帮手函数和类像我的命名空间;然而,所有这一切都可以访问到C#
  5. VB是不区分大小写

C#的语法遵循类似的语法C和Java,这使其成为一个更舒适的那些语言,在这里为VB可以更舒服的VB用户过渡。至于性能,和库或组件它们几乎是一样的。

C#'s syntax follow a similar grammar to c and java, which make it a much more comfortable transition from those languages, where as VB can be more comfortable to VB users. As far performance, and libraries or components they are nearly identical.

至于哪一种选择,除非你有必要做不安全的操作,然后选择它是最自然的,你的语言。经过多年作为一个VB开发人员,我爱没有写如果yadada然后.....结束如果如果(yadaya){....}救了我的腕管了一些额外的按键(然后可以在回答这样用问题)

As for which one to choose, unless you have a need to do unsafe operations, then choose the language which is most natural to you. After years of being a VB developer I loved not having to write If yadada then.....End If if (yadaya){....} saves my carpal tunnel a few extra keystrokes (Which can then be used on answering SO questions)

刚刚获悉一个更多的差异BTW C#和VB的是,VB支持过滤例外,所以你可以像这样的伪:

Just learned one more difference btw C# and VB is that VB supports filtered exceptions so you could something like this pseudo:

try
{
   //do something that fails
}
catch(Exception ex when ArgumentException, 
      ArgumentNullException, FormatException)
{
  //Only handle these three types
}

这不应该与能力做困惑:

This should not be confused with the ability to do:

   try
   { 
      //something that fails
   }
   catch(ArgumentException)
   { 
      //Log Error

   }
   catch(ArgumentNullException)
   {
     //Log Error
   }

在这种情况下,你会以不同方式处理异常在VB世界里,你可以定义一条code处理多种类型的异常。

In this case you are going to handle the exceptions differently in the VB world you could define one piece of code to handle multiple types of Exceptions.

一些更多的差异。

  1. VB的运营商是比较两个对象,以确定它们是否是编译的CEQ IL指令,其中的C#编译为isinst IL相同。所以,下面的是等效的声明

C# 如果(foo是FooObject){}

VB 如果TypeOf运算foo是FooObject然后

  1. 另外中提到的意见,我希望我能看到他们给你的信用,但是C#没有一个像参数。你需要使用正则表达式类。

这篇关于C#的优势在VB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆