这两个数组有什么区别? [英] What is difference between these two arrays?

查看:147
本文介绍了这两个数组有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


这两个数组的声明有什么区别?

Hi,
What is difference in declaration between these two arrays?

int[] array1 = new int[] { 1, 3, 5, 7, 9 };




and

int[] array1 = { 1, 3, 5, 7, 9 };

推荐答案

没有区别.

如果您反汇编有问题的代码片段并查看IL代码,则将节省大量时间.即使您不了解IL,也可以弄清楚什么是相同的,什么不是.请参阅:
http://msdn.microsoft.com/en-us/library/f7dy01k1%28v = vs.100%29.aspx [ ^ ],
http://en.wikipedia.org/wiki/ILDASM [
There is no difference.

You will save a lot of time if you disassemble code fragments in question and look at IL code. Even if you don''t understand IL, you will be able to figure out what is identical and what is not. Please see:
http://msdn.microsoft.com/en-us/library/f7dy01k1%28v=vs.100%29.aspx[^],
http://en.wikipedia.org/wiki/ILDASM[^].

—SA


都没有.
第一种只是一种明确声明编译器应该使用哪种类型的方法.在以后的版本中,它可以从上下文中解决问题.
None whatsoever.
The first is just a way to explicitly state what type the compiler should expect. In the later, it works it out from the context.


没有,这只是语法问题.它们都是相同的类型,这就是告诉第二种语法期望的内容.
None, it''s just a question of syntax. They are both of the same type, which is what tells the second syntax what to expect.


这篇关于这两个数组有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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