Tuesday, May 19, 2009

For Pascal fans who are forced to muddle thru the joys of C#

I remember many fun things about Pascal...memory overlays were not fun, but Pascal had many fun little pieces of syntax that I miss. The "in" operator was one of them. I went looking for it today in C#...naturally I didn't find it. I did find a great little shorthand for something simliar in this forum:

The old Pascal syntax was:

if (i in [1,3,5..10])

The fun little shorthand in C#:

if (Array.IndexOf(new int[] { 1, 3, 5, 10 }, i) != -1)

Thanks, Larry Smith.

No comments: