I would like to assign the variable vStreamID random number. This number must be re-generated, if my dictionary md_StreamDict contains 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 like LINQ
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 was a real way to achieve this. And no, we are not starting the usual discussion of readability again.;)
source share