Click to See Complete Forum and Search --> : [RESOLVED] VS2010 Intellisense


dannystommen
April 22nd, 2010, 07:33 AM
Hi all,

I started this week using VS2010. And now I see something strange (at least, I've never seen it in VS08).

In the intellisense (see image), I can see 'queryString:' and 'queryStrings'. What does the first one mean?

TechGnome
April 22nd, 2010, 08:45 AM
It's a feature of .NET... Named Parameters... That means you can pass in your parameters in any order, as long as you specify the named parameter, followed by a colon (in C#.... in VB it's colon-equals := ) and the value.

So let's say I have a function void doSomething(string myMessage, int32 timerVal)

I can call it thusly:
doSomething("Hi there", 300)
Or
doSomething(myMessage:"Hi there", timerVal:300)
Or
doSomething(timerVal:300, myMessage:"Hi there")


What's the advantage? I don't know. Other than being able to specify your parameters in any order, and at least then it's explicit what each parameter is (I've found myself checking out the procedure's signature countless time going "What is this parameter I'm passing in?")... there's not much else for it.

-tg

dannystommen
April 22nd, 2010, 08:53 AM
Another day at work I learned something new :-)

Thnks!

boudino
April 22nd, 2010, 02:03 PM
You are right: it's strange. I don't understood named parameters at all.

TechGnome
April 22nd, 2010, 03:12 PM
More often than not, I see them used with optional parameters (something that's in VB, not sure if C# supports it or not).

-tg

eclipsed4utoo
April 26th, 2010, 12:05 PM
More often than not, I see them used with optional parameters (something that's in VB, not sure if C# supports it or not).

-tg

Optional Parameters were added to C# in .Net 4 (C# 4.0).