I have this code :
(simple enum which has values for a,b,c …[0,1,2] , and i want to show for each looped number – its corrosponding enum in a final list).
public enum ENM
{
a,b,c
}
void Main()
{
var e = Enumerable.Range(0,3).Select(myCounter=>new {
final=((Func<int,ENM>)delegate (int i)
{
return (ENM)i;
})(myCounter)
}).ToList();
this is fine and working.
Is there any solution without writing delegate(int i) {...}?
p.s. of course I can just write (ENM)i but the question is for learning
how to write ( in different ways ) the auto-executed methods.
Why not
or am I missing some reason for the over complexity?
is about as tight as you will get if you want the same mess 🙂