任何人发现使用" VAR"比LINQ其他? [英] Anyone found a use of "var" other than for LINQ?

查看:94
本文介绍了任何人发现使用" VAR"比LINQ其他?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是好奇。 ?我约99.999%肯定是没有的......但什么

Just curious. I'm about 99.999% sure there is none...but anything?

编辑:这些都是OK的回答(节省打字时间或使代码为可读性更简洁)。我想我应该澄清我的意思是用 - 一些结构/设计,不能没有VAR来完成。

These are OK answers (saving typing time or making the code less verbose for "readability"). I guess I should have clarified what I meant by "use" - some construct/design that couldn't be done without "var" .

推荐答案

请告诉我更好的可读性方面?

Whats better in terms of readability?

AReallyReallyLongBusinessObjectName obj = new AReallyReallyLongBusinessObjectName();

var obj = new AReallyReallyLongBusinessObjectName();



我说,在可读性方面,因为使用VAR绝对没有看到,因为这两种说法对你的应用程序的影响。编译时会产生相同的IL

I say in terms of readability because using var has absolutely no impact on your app seeing as the two statements generate the same IL when compiled.

响应编辑:有什么要求您使用VAR(除匿名类型) - 其只是语法糖。

Response to edit: there is nothing that requires you to use var (other than anon types) - its just syntactic sugar.

这篇关于任何人发现使用" VAR"比LINQ其他?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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