Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why there are the same variables of mine with a ':' in Visual Studio auto complete list?

What's the difference between myVar and myVar: in VS auto-complete list while working with functions. Why the second one is added to this list ?

like image 986
Xaqron Avatar asked Dec 14 '10 15:12

Xaqron


Video Answer


1 Answers

C# 4.0 introduced named arguments. This feature allows you to identify method arguments by their names instead of their position:

public void Foo(int bar, string quux)
{
}

// Before C# 4.0:
Foo(42, "text");

// After C# 4.0:
Foo(bar: 42, quux: "text");

// Or, equivalently:
Foo(quux: "text", bar: 42);

Intellisense has been updated to support that feature, that's why its autocompletion mechanism now offers both choices when a symbol accessible from the current scope has the same name as a method argument.

like image 164
Frédéric Hamidi Avatar answered Sep 27 '22 22:09

Frédéric Hamidi