views:

338

answers:

2

Hey everyone,

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?

+16  A: 

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

Darin Dimitrov
More accurately, named arguments. Parameters have always had names :)
Jon Skeet
simple, complete, correct
Kris
@Jon Skeet: dude, you do realize you're the only guy that knows the difference between parameters and arguments right? ;-)
Kris
Very nice. Thanks!
Jim B
@Jon, thanks, updated.
Darin Dimitrov
@Kris, simple, complete and correct questions always get simple, complete and correct answers :-)
Darin Dimitrov
@Kris: I'm hoping that eventually the rest of the world will care :)
Jon Skeet
+7  A: 

The colon is necessary to indicate parameters. In C# 4.0, you can re-order and name your parameters, optionally, but the variable name must match the prototype and have the colon postfix.

public void Test(string something1, string something2)
{
}

can be called as:

Test(something2: "bar", something1: "foo");

if you want

Brian Genisio
Thanks for providing an illustration, not just a link.
DOK