TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

C# has var now?

1 点作者 jebblue超过 9 年前

2 条评论

thelastguy超过 9 年前
Var just makes it harder to read C# code. For example, the difference between...<p>int foo = object.GetSomething() vs var foo = object.GetSomething()<p>The int makes it easy for you to instantly identify that foo is an integer. In the var example, what the fuck is foo? A string? A class? An integer? To find out, you must rely on Visual Studio&#x27;s Intellisense and hover your mouse over foo for a few secons, before Visual Studio will tell you what type foo is. This slows your code reading considerably. And if you don&#x27;t have Visual Studio, then you have to go waste time reading the documentation to figure out what type foo is.<p>Sure, it save your typing time, but, it waste other developer&#x27;s reading time.
评论 #10083453 未加载
jebblue超过 9 年前
I&#x27;m trying my hand at getting back into some C# coding and found that apparently the language now has var. My first thought was why would a professional, statically typed language have var. Checking out the page I linked to in the submission, you can also do this cool if not slightly funky looking thing where it looks like an SQL predicate just reading from an ordinary array.
评论 #10083467 未加载
评论 #10070163 未加载