question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What about having something like:

Array.prototype.toList = function<T>(): List<T> {
    return new List<T>(this);
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
isc30commented, Jan 26, 2017

C# Array has GetEnumerator() that returns IEnumerable (the one you call List in your code).

Btw as IEnumerable has one extension method called ToList(), you can call .ToList() in a Array<T>.

Demo:

int[] a = {2, 3, 4, 5}; // Array<int>
var l = a.ToList(); // Array<int> -> IEnumerable<T> -> List<int>
l.Add(33);
Console.WriteLine(string.Join(",", l));

>> 2,3,4,5,33

And yes, everything is inside System.Linq namespace

0reactions
isc30commented, Jan 26, 2017

Yep, I agree that changing native prototypes isn’t a good idea. I open another issue to discuss other topic. You can close this one

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java ArrayList - W3Schools
The ArrayList class is a resizable array, which can be found in the java.util package. The difference between a built-in array and an...
Read more >
ArrayList (Java Platform SE 8 ) - Oracle Help Center
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. Parameters: c -...
Read more >
ArrayList in Java - GeeksforGeeks
ArrayList is a part of the Java collection framework and it is a class of java.util package. It provides us with dynamic arrays...
Read more >
ArrayList in Java - javatpoint
Java ArrayList class uses a dynamic array for storing the elements. It is like an array, but there is no size limit. We...
Read more >
Java ArrayList (With Examples) - Programiz
Unlike arrays, arraylists can automatically adjust their capacity when we add or remove elements from them. Hence, arraylists are also known as dynamic...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found