Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
250 views
in Technique[技术] by (71.8m points)

C# syntax - Colon after a variable name

Quick question; I've recently upgraded to VS2010, and got the new version of ReSharper.

Now, when ReSharper is giving me autocomplete options for a variable, it give me the option of <variableName>:

What does the : stand for?

For example; I have this:

var productIds = new List<int>(inventoryItemsToProcess.Keys);

And when I start typing out a line like this:

var lastOrderDates = GetProductLastOrderDates(pro

It gives me the option for productIds as well as productIds:

What's the difference between the two?

question from:https://stackoverflow.com/questions/3283781/c-sharp-syntax-colon-after-a-variable-name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The second is for C# 4.0 named arguments. And here's a link on MSDN.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...