Reputation: 3637
I'm reviewing this code (written in C#):
string root = match.Groups[1].Value,
secon = match.Groups[2].Success ? match.Groups[2].Value.Substring(1) : string.Empty,
third = match.Groups[3].Success ? match.Groups[3].Value.Substring(1) : string.Empty;
Can someone explain the purpose of the commas?
Upvotes: 1
Views: 181
Reputation: 74257
It's a syntactic shortcut. Your example above is syntactic sugar for and is exactly the same as:
string root = match.Groups[1].Value ;
string secon = match.Groups[2].Success ? match.Groups[2].Value.Substring(1) : string.Empty ;
string third = match.Groups[3].Success ? match.Groups[3].Value.Substring(1) : string.Empty ;
So it saves you a little typing.
That is all.
Upvotes: 3
Reputation: 13248
They are used as a shortcut to create variables, and, in your example, all of which are of type string
.
Upvotes: 0
Reputation: 7591
It declares 3 variables of the type string
named root
, secon
and third
respectively. Like this:
int a, b, c;
Upvotes: 5