This is a hack and I know it is but I like how easy it is.
I've been doing a ton of JavaScript lately and this has been bleeding into my C#. I needed to check values in a set during a LINQ query against a small set and came up with
new [] { 1, 2, 3 }.Contains(value)
That did the trick!
Now, would I deploy this in production? Definitely not. I can't put it in a constant so my best bet would be a static array. No sense building up and destroying the array every time the function is called.
Still a neat little trick.
JavaScript like Arrays in C#
Friday, March 22, 2013 at 10:58 AM Posted by Eric
Subscribe to:
Posts (Atom)