Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One-line memvars declaration

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
566
0
16
US
Colleagues,

I'm kinda new to C#, "kinda" - coz I haven't been working with it since 2007 and forgotten some even simple things like the one in subject.
Now I'm back to C# (VS 2012 .NET) and trying to restore my skills.
So, quick question:
I vaguely remember that C# allowed (local) memvars' declaration like this:

C#:
string sVar1 = sVar2 = sVar3 = sVar4 = "";

Am I correct, or my (deteriorating) memory plays some sick trick on me and it was some other language?

P.S. Didn't find neither confirmation nor denial in MS's documentation, hence posting here.

Regards,

Ilya
 
P.S. Scratch it off.
It's
Code:
string sVar1, sVar2, sVar3;
sVar1 = sVar2 = sVar3 = ""

("With age, eyesight is the 2nd thing to go, and I can't remember what the 1st one is..." :-( )

Regards,

Ilya
 
Would have thought it would be simpler as
Code:
string sVar1 = "", sVar2 = "", sVar3 = "";
Then it would be a true one-liner.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top