I'd like to assign the variable vStreamID
with a random number. This number should be newly generated as long as my dictionary md_StreamDict
contains the generated number.
Long version:
vStreamID = (new Random()).Next(1000, 9999).ToString();
while (md_StreamDict.ContainsKey(vStreamID)) {
vStreamID = (new Random()).Next(1000, 9999).ToString();
}
I would like to see something LINQ style
md_StreamDict.ContainsKey(vStreamID)
.while( x => x = (new Random())
.Next(1000, 9999)
.ToString();
I know the example above is bananas. But I would be happy if there's a real way to achieve this. And no, we're not starting the usual discussion about readability again. ;)