You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I’d like to see, is adding extension methods for Arrays so that they have the same interface as Lists for all the basic functions. Find, Contains, IndexOf, Sort etc. I find that newer devs don’t realize that the functionality already exists but is hidden behind the Array prefix, so it doesn’t show up in Intellisense like it would with a List, or other collection. So they tend to fall back onto LINQ versions which are a little slower due to the cast, or rewriting an array walk to find an element/index. It’d be nice if there was a concrete set of methods for them to fall into first. (I do this on some of our projects, but it’d be even better if it was already inherent)
IE Array.Exists, Array.FindIndex, Array.Clear, Array.Find, are easily missed, as the usual way to way to see what methods one can call on a variable are 'foo.' and letting intellisense fill out the list of options. So having to type 'Array.' doesn't even come to mind.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
What I’d like to see, is adding extension methods for Arrays so that they have the same interface as Lists for all the basic functions. Find, Contains, IndexOf, Sort etc. I find that newer devs don’t realize that the functionality already exists but is hidden behind the Array prefix, so it doesn’t show up in Intellisense like it would with a List, or other collection. So they tend to fall back onto LINQ versions which are a little slower due to the cast, or rewriting an array walk to find an element/index. It’d be nice if there was a concrete set of methods for them to fall into first. (I do this on some of our projects, but it’d be even better if it was already inherent)
IE Array.Exists, Array.FindIndex, Array.Clear, Array.Find, are easily missed, as the usual way to way to see what methods one can call on a variable are 'foo.' and letting intellisense fill out the list of options. So having to type 'Array.' doesn't even come to mind.
EDIT:
Static class ArrayExtensions
{
T? Find(this T[] Array, Predicate match) => Array.Find(array,match);
}
Beta Was this translation helpful? Give feedback.
All reactions