Reputation: 20790
How can I enumerate all possible instances of System.Char ? I need to see for which ones System.Char.IsSymbol returns true, for example.
Upvotes: 2
Views: 1624
Reputation: 23324
for (var c = System.Char.MinValue; c != char.MaxValue; ++c)
DoSomething(c);
DoSomething(char.MaxValue);
Upvotes: 1
Reputation: 30701
Linq-y answer to give you the symbol characters:
var chars = Enumerable.Range(0, char.MaxValue+1)
.Select(i => (char) i)
.Where(c => char.IsSymbol(c))
.ToArray();
Credit really should go Sir Skeet, whose answer here it's based on.
Upvotes: 4
Reputation: 25551
for (int i = char.MinValue; i <= char.MaxValue; i++) {
char c = Convert.ToChar(i);
if (!char.IsSymbol(c)) {
//kung-fu!
}
}
Upvotes: 4