-1

In VB.NET, I can do this:

MyArray.Select(Function(a)
                   Dim x as string
                   x = a
                   Return x
               End Function)

How can I do this in c#?

oscilatingcretin
  • 10,457
  • 39
  • 119
  • 206

2 Answers2

2
myArray.Select(a => {
    ...
});
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

It looks like the VB.Net is just selecting each element in MyArray, in c#

MyArray.Select(a => (string) a);

To make it a method, use braces:

MyArray.Select(a =>
 {
   ...
   return ...;
 });
Richard Schneider
  • 34,944
  • 9
  • 57
  • 73