哪个更好,C#或VB,为什么? [英] Which is better, C# or VB, and why?

查看:67
本文介绍了哪个更好,C#或VB,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经研究了这个问题一段时间了,不能得出任何结论性的

答案,大多数似乎是对语法的偏好,有人说c#是

优雅,而vb很笨重,或者说c#是令人讨厌的,而vb更自然是

清晰易读。在一个上面似乎没有很多功能,至少与whidbey相同,所以基本上,有什么c#可以做到vb不能吗?

i''ve been researching this issue for a while and can''t come to any conclusive
answer, mostly it seems to be a preference over syntax, some saying c# is
elegant while vb is clunky, or that c# is geeky while vb is more naturally
legible. there dont seem to be many capabilities in one over the other, at
least with whidbey, so basically, is there anything c# can do that vb can''t?

推荐答案



" lastusernameleft" < LA ************** @ discussions.microsoft.com>写在

消息新闻:F4 ********************************** @ microsof t.com ...

"lastusernameleft" <la**************@discussions.microsoft.com> wrote in
message news:F4**********************************@microsof t.com...
我已经研究了这个问题一段时间了,无法回答任何确定的答案,大多数情况下似乎是偏好语法,有些人说c#是优雅的,而vb是笨重的,或者说c#是怪异的,而vb更自然是清晰易读的。在一个上面似乎没有很多功能,至少与whidbey一样,所以基本上,有什么东西可以做c#
不能吗?
i''ve been researching this issue for a while and can''t come to any
conclusive
answer, mostly it seems to be a preference over syntax, some saying c# is
elegant while vb is clunky, or that c# is geeky while vb is more naturally
legible. there dont seem to be many capabilities in one over the other, at
least with whidbey, so basically, is there anything c# can do that vb
can''t?




每种语言都有一些不同的东西。在1.x VB中,当选项严格关闭时,它有动态绑定模式,并且在C#支持的情况下可以访问一些像参数化属性这样的小东西(我相信)

用于指针,无符号tyupes和运算符重载。


在whidbey中,VB添加了运算符重载和直接支持无符号

类型以及其他一些细节(如OrElse和AndAlso,IIRC),但

语言实际上只是比它们更多的分歧。

得到了泛型和部分类型,但是VB的大部分工作都投入了很多东西

就像编辑和继续一样(C#基本上已经很快就加入了这个行列), />
我的命名空间,以及我之前提到过的东西,而C#添加了一些小的

,就像接近闭包和迭代器的匿名方法一样。


我认为anon方法是我认为唯一的优势。迭代器

很好,但是IEnumerable\IEnumerator实现不是*那个*很难

手动编写。除此之外,我没有看到很多优势,除了

个人喜好或非常特殊的情况(C#指针骑行,

本机代码或VB for rich COM工作,办公自动化等)



Each language has a few, little things different. In 1.x VB has its
dynamically bound mode when option strict is off and has access to a few
little things like parameterized properties(I believe) while C# has support
for pointers, unsigned tyupes, and operator overloading.

In whidbey, VB added operator overloading and direct supprot for unsigned
types as well as some other niceties(like OrElse and AndAlso, IIRC), but the
languages actually diverged just a little bit moreso than they were. Both
got generics and partial types, but much of the VB effort went into things
like Edit&Continue(C# basically hopped on that bandwagon pretty late), the
My namespace, and the things I mentioned before while C# added a few little
thigns like anonymous methods that are close to closures and iterators.

I think anon methods are the only thing I''d consider an advantage. Iterators
are nice but IEnumerable\IEnumerator implemetnations are not *that* hard to
write manually. Out side of that I don''t see much advantage except for
personal preference or in very specific circumstnaces(C# for pointer ridden,
native code or VB for rich COM work, office automation for example)


C#可以使用无符号整数数据类型,你可以编码''不安全''代码

blocks 。如果您需要这些功能,您已经知道了。大多数人从来没有b $ b b需要它们。


VB.Net在后期绑定方面更胜一筹,如果你需要,它有时非常有用

与某些外部应用程序(如MS Office)进行交互。当然,C#可以做到
,但需要更多的代码。如果您在

VB.Net中打开Option Strict,就像你应该的那样,坚持数据类型

匹配就像C#一样好。


VB进行后台编译,并且更快地向您显示编码错误

(保持任务列表窗口可见并立即获得反馈)。如果你有一个非常大的解决方案,并且你的处理器速度不快,那么这可能会导致编辑响应速度变慢。另一方面,C#不会在你编译之前显示大多数错误。


性能将是相同的(假设你避免

VisualBasic.Compatibility程序集,作为人们的拐杖提供

尝试使用升级向导从VB6中提取代码)。向导

几乎被普遍认为是无用的。


除此之外,在它们之间没有其他选择。如果你喜欢

花括号和区分大小写,你会喜欢C#。如果你来自VB 6

背景并且喜欢不必匹配变量的情况那么

当你输入时,你会喜欢VB.Net 。你仍然需要正确拼写名称

,但VB.Net对匹配案例很放松。在整个代码中,

声明规则中的大小写,编辑器将在您编辑过去的行后为您更正

大小写。 VB.Net多一点

详细:开始',然后'',结束如果',等等而不是花括号,

但是如果你是一个熟练的触摸打字员,这不是什么大不了的事。


有些人似乎认为C#代码看起来干净,这真的是一个

美学问题。编译器不在乎,但是如果你同意并且可以自由地生成

,那么你没有理由要求b $ b不应该考虑到这一点。你在此基础上的决定。我倾向于,我自己也同意这种观点,

但不是因为我限制了我的选择。


有一支队伍倾向于瞧不起鼻子的C#程序员在VB.Net中编程的人是b
$ b。如果这会打扰你,并且在我的

意见中这是他们的问题,而不是VB.Net程序员的问题,你可能会想要b / b
想要倾向于C#。他们可能有点野蛮,但大部分时间他们互相咆哮,而不是把它带到街上;-)


似乎作为一个小证据,平均而言,C#程序员可能会获得略高的薪水。这可能与感知到的概念相关联,即C#程序员比VB.Net程序员更聪明或更好。

(当然,我在这里谈论的是专业人士)程序员,而不是

爱好者)。


无论你做什么,学习两种语言,无论你决定使用哪种语言

使用(或者是由其他人决定的)。有电脑的学生

科学背景应该能够在不超过

三天左右的时间内学习一门新语言。掌握框架类库将是你必须面对的最大的障碍,无论你使用哪种语言,这种努力都是一样的。


我个人在哪里?在1991年VB出来之前,我是一个很开心的C / C ++程序员,很长一段时间。我多年来转向VB编程,

从VB 1.0开始,然后通过VB上升6,随着VB的成长,在C语言系列中编写越来越少的助手

代码。当我进入.Net时,我/ b $ b开始编程,充分利用我对两个语言家族的熟悉程度。如果我碰巧在我想要了解的框架中选择了运行

的代码示例,我只是继续使用示例中的

语言。如果我从头开始一个新项目,我通常会用C#开始它。$

我正在工作的公司做出了决定,在我加入之前,

他们将在VB.Net中开发,所以这就是我用的,没有抱怨,

当我为他们编程时。


HTH,

Tom Dacon

Dacon Software Consulting


" lastusernameleft" < LA ************** @ discussions.microsoft.com>写在

消息新闻:F4 ********************************** @ microsof t.com ...
C# can use the unsigned integer data types, and you can code ''unsafe'' code
blocks. If you need these features, you already know it. Most people never
have a need for them.

VB.Net is better at late binding, which is sometimes very useful if you need
to interact with certain external applications such as MS Office. C# can do
it, of course, but it takes more code. If you turn Option Strict on in
VB.Net, as you should, it''s just as good about insisting on data type
matching as C# is.

VB does background compiles and is quicker at showing you coding errors
(keep the task list window visible and you get immediate feedback). If you
have extremely large solutions and your processor isn''t fast, this can
sometimes slow down editing responsiveness. C#, on the other hand, doesn''t
show you most errors until you compile.

Performance will be the same (provided you avoid the
VisualBasic.Compatibility assembly, which is supplied as a crutch for people
trying to use the upgrade wizard in bringing code up from VB6). The wizard
is almost universally considered to be pretty much useless.

Other than that, there''s not much else to choose between them. If you like
curly braces and case-sensitivity, you''ll like C#. If you came from a VB 6
background and like not not having to match the case of variables and so
forth when you type, you''ll like VB.Net. You still have to spell the names
correctly, but VB.Net is relaxed about matching case. The casing in the
declarations rules throughout the code, and the editor will correct the
casing for you after you edit past the line. VB.Net is a little more
verbose: Begin''s, Then''s, End If''s, and so forth instead of curly braces,
but if you''re a skilled touch typist this isn''t much of a deal.

Some people seem to think that C# code looks ''cleaner'', which is really an
issue of aesthetics. The compilers don''t care, but there''s no reason why you
shouldn''t take that into account if you agree and have the freedom to make
your decision on that basis. I tend, myself, to agree with that sentiment,
but not to the extent that I let it limit my options.

There''s a contingent of C# programmers who tend to look down their noses at
people who program in VB.Net. If this is going to bother you, and in my
opinion it''s their problem, not that of the VB.Net programmers, you might
want to gravitate to C#. They can be a little savage, but mostly they rant
about it among themselves rather than taking it to the streets ;-)

There''s seems to be a little evidence that on average C# programmers might
get slightly higher salaries. This is probably tied to a perceived notion
that C# programmers are somehow smarter or better than VB.Net programmers
(here, of course, I''m talking about professional programmers, not
hobbyists).

Whatever you do, learn both languages, regardless of which one you decide to
use (or have decided for you by someone else). Someone with a computer
science background should be able to pick up a new language in no more than
three days or so. Mastering the framework class library will be the biggest
hurdle you have to face, and that effort will be the same no matter which
language you settle on.

Where do I come down on this personally? I was a happy C/C++ programmer long
before VB came out in 1991. Over the years I moved into VB programming,
starting with VB 1.0 and going up through VB 6, writing less and less helper
code in the C language family as VB grew up. When I moved into .Net, I
started out programming in both, leveraging my familiarity with both
language families. If I happened to pick up a code sample that exercised
something in the framework I wanted to learn about, I just continued in the
language of the sample. If I start a new project from scratch, I usually
start it out in C#.

The company I''m working for now made the decision, before I joined them,
that they would develop in VB.Net, so that''s what I use, without complaint,
when I''m programming for them.

HTH,
Tom Dacon
Dacon Software Consulting

"lastusernameleft" <la**************@discussions.microsoft.com> wrote in
message news:F4**********************************@microsof t.com...
我已经研究了这个问题一段时间了,不能找到任何
的结论性答案,大多数情况下似乎是对语法的偏好,有些人说c#是优雅的,而vb很笨重,或者说c#是怪异的,而vb更自然是清晰易读的。在其中一个似乎没有很多功能,至少与whidbey一样,所以基本上,有什么c#可以做什么vb
i''ve been researching this issue for a while and can''t come to any conclusive answer, mostly it seems to be a preference over syntax, some saying c# is
elegant while vb is clunky, or that c# is geeky while vb is more naturally
legible. there dont seem to be many capabilities in one over the other, at
least with whidbey, so basically, is there anything c# can do that vb



不能?


can''t?


我的头顶:


C#允许:

- '''不安全' '指针代码,如果你倾向于那样。

- 表达式中的赋值(例如,while((i = s.IndexOf(y))> -1))

- 允许匿名方法 - 我不相信VB会在2005年包含它。


VB允许:

- 接口内的类型。

- With构造(但它的价值是值得商榷的)。

- 在保留内容(ReDim Preserve)的同时调整数组大小的简写,

但你也可以在C#中完成有4行代码。

- 这是非常简单的,但是VB有什么时候。 Catch声明的子句,

没有优雅的C#等价物。


David Anton
www.tangiblesoftwaresolutions.com

主页:

即时C#:VB.NET转C#转换器

即时VB:C#到VB.NET转换器

即时J#:VB.NET到J#转换器


" lastusernameleft" ;写道:
Off the top of my head:

C# allows:
- ''unsafe'' pointer code if you''re inclined that way.
- assignments within expressions (e.g., while ((i = s.IndexOf(y)) > -1))
- allows anonymous methods - I don''t believe VB will include that in 2005.

VB allows:
- types within interfaces.
- the "With" construct (but it''s value is debatable).
- a shorthand for array resizing while preserving contents (ReDim Preserve),
but you can do it in C# also with 4 lines of code.
- this is pretty trivial, but VB has the "When" clause for Catch statments,
which has no elegant C# equivalent.

David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter

"lastusernameleft" wrote:
我已经研究了这个问题一段时间了,不能得出任何结论性的答案,大多数似乎是对语法的偏好,有些人说c#是优雅的,而vb很笨重,或者说c#是怪异的,而vb更自然是清晰易读的。在其中一个似乎没有很多功能,至少在whidbey,所以基本上,有什么c#可以做到vb不能吗?
i''ve been researching this issue for a while and can''t come to any conclusive
answer, mostly it seems to be a preference over syntax, some saying c# is
elegant while vb is clunky, or that c# is geeky while vb is more naturally
legible. there dont seem to be many capabilities in one over the other, at
least with whidbey, so basically, is there anything c# can do that vb can''t?



这篇关于哪个更好,C#或VB,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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