是C#VB.NET比快? [英] Is C# faster than VB.NET?

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

问题描述

您会认为两者是相同的。



不过也许它是微软使用的编译器,但我注意到,编译两个非常小的程序,相同的逻辑时。 VB.NET使用更多的IL指令。



这是真的比C#一定要快,如果仅仅是因为它的编译器是聪明的。


< DIV CLASS =h2_lin>解决方案

这是真的很难用现有的资料数量有限回应明确。这将有助于很多,如果你提供的两个样品和所使用的编译器选项的代码。



要尽管回答这个问题,没有C#本身并不快。这两种语言产生于IL和在CLR上运行。对于大多数功能,甚至产生相同的IL。还有一些类似的功能差异,但他们很少加起来显著的性能变化。



如果你碰到一些在语言和环境的细微差别VB可以出现慢。一对夫妇的常见的例子是...




  • 许多环境默认为VB.Net检查整数操作而不是C#

  • 微妙的编码问题可能会导致后期绑定它似乎是早期绑定

  • 相信开关选择具有相同的语义



一旦这些被删除的语言具有非常相似的性能进行配置文件。


You'd think both are the same.

But maybe it's the compiler that Microsoft has used, but I've noticed that when compiling two very small programs, identical logic. VB.NET uses more IL instructions.

Is it true than that c# must be faster, if only because its compiler is smarter.

解决方案

This is really hard to respond to definitively with the limited amount of information available. It would help a lot if you provided the code from both samples and the compiler options used.

To answer the question though, no C# is not inherently faster. Both languages generate to IL and run on the CLR. For most features they even generate the same IL. There are differences for some similar features but they rarely add up to significant performance changes.

VB can appear slower if you run into some of the subtle differences in the languages and environment. A couple of common examples are ...

  • Many environments default to checked integer operations for VB.Net but not C#
  • Subtle coding issues can lead to late binding where it appears to be early binding
  • Believing switch and Select have the same semantics

Once these are removed the languages perform with very similar performance profiles.

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

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