Click here to Skip to main content
15,891,372 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: MDAC Pin
Scott Dorman6-Jan-08 5:16
professionalScott Dorman6-Jan-08 5:16 
GeneralRe: MDAC Pin
Mike Dimmick6-Jan-08 7:46
Mike Dimmick6-Jan-08 7:46 
GeneralRe: MDAC Pin
Scott Dorman6-Jan-08 7:50
professionalScott Dorman6-Jan-08 7:50 
QuestionHelp Needed Pin
Arunava354-Jan-08 18:52
Arunava354-Jan-08 18:52 
GeneralRe: Help Needed Pin
DigiOz Multimedia5-Jan-08 8:51
DigiOz Multimedia5-Jan-08 8:51 
GeneralRe: Help Needed Pin
Arunava355-Jan-08 16:56
Arunava355-Jan-08 16:56 
GeneralRe: Help Needed Pin
DigiOz Multimedia6-Jan-08 2:32
DigiOz Multimedia6-Jan-08 2:32 
QuestionString index Pin
kalkwarf4-Jan-08 9:38
kalkwarf4-Jan-08 9:38 
I am enumerating through a collection where the index is a string. I would like to get my hands on that string.

I am working with regular expression named groups, but the issue is the same for any collection indexed with strings.

An example:

Regex regEx = new Regex(@"^(?<name>\w+):(?<value>\w+)");<br />
Match match = regEx.Match("abc:123");<br />
GroupCollection groups = match.Groups;<br />
<br />
Console.WriteLine(groups["name"]);<br />
Console.WriteLine(groups["value"]);



(Note that the sad face emoticon in the first line should be a colon followed by a left parenthesis. I could not turn this off.)

The above writes the following to the Console:

abc
123

I would like to also write the index so the output looks like:

name = abc
value = 123

Ideally, I would like to use a foreach to print all indexes and values in the collection. This would look something like:

foreach (Group group in match.Groups)<br />
{<br />
   Console.WriteLine(??? + " = " + group.Value);<br />
}


I cannot figure out what "???" should be.


Thanks.
GeneralRe: String index Pin
Paul Conrad26-Jan-08 7:23
professionalPaul Conrad26-Jan-08 7:23 
GeneralRe: String index Pin
kalkwarf28-Jan-08 2:59
kalkwarf28-Jan-08 2:59 
GeneralRe: String index Pin
Paul Conrad28-Jan-08 13:53
professionalPaul Conrad28-Jan-08 13:53 
GeneralLinq Pin
Tad McClellan4-Jan-08 3:54
professionalTad McClellan4-Jan-08 3:54 
GeneralRe: Linq Pin
Tad McClellan4-Jan-08 4:02
professionalTad McClellan4-Jan-08 4:02 
GeneralRe: Linq Pin
originSH4-Jan-08 4:04
originSH4-Jan-08 4:04 
GeneralRe: Linq Pin
originSH4-Jan-08 4:09
originSH4-Jan-08 4:09 
GeneralRe: Linq Pin
led mike4-Jan-08 4:28
led mike4-Jan-08 4:28 
GeneralRe: Linq Pin
originSH4-Jan-08 5:06
originSH4-Jan-08 5:06 
GeneralRe: Linq Pin
Tad McClellan4-Jan-08 10:59
professionalTad McClellan4-Jan-08 10:59 
GeneralRe: Linq Pin
Colin Angus Mackay4-Jan-08 5:12
Colin Angus Mackay4-Jan-08 5:12 
GeneralRe: Linq Pin
Pete O'Hanlon4-Jan-08 10:08
mvePete O'Hanlon4-Jan-08 10:08 
GeneralRe: Linq Pin
N a v a n e e t h7-Jan-08 1:05
N a v a n e e t h7-Jan-08 1:05 
GeneralRe: Linq Pin
Pete O'Hanlon7-Jan-08 1:26
mvePete O'Hanlon7-Jan-08 1:26 
GeneralRe: Linq Pin
N a v a n e e t h7-Jan-08 2:53
N a v a n e e t h7-Jan-08 2:53 
GeneralRe: Linq Pin
Pete O'Hanlon7-Jan-08 3:12
mvePete O'Hanlon7-Jan-08 3:12 
GeneralRe: Linq Pin
Mark Churchill7-Jan-08 12:37
Mark Churchill7-Jan-08 12:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.