Alex Rivera | Logout

Arrays.asList( ... ) in .Net

Asked 2011-03-10T12:10:17.287
12

I am looking for the simplest way to write the following Java code

Arrays.asList(1L);

in .Net

Thanks

Edit
Report

1 Answer

0

The implementation of that static method looks like this.

public static <T> List<T> asList(T... a) {
return new ArrayList<T>(a);
}

The equivalent for You wold be write same utility class with method asList in C# or use the solution presented by Massif.

public static class Arrays {
      public static List<T> asList<T>(params T[] a)
        {
            return new List<T>(a);

        }
}
answered 2011-03-10T12:48:37.737

Your Answer