c# - Remove last x elements from the list -


lets have list<car> cars have n items , want delete last two. best way found is:

cars.removerange(cars.count-2, 2);

is there better way? searching this:

cars.removefrom(cars.count-2); //pseudocode

no, there isn't... if want can put in extension method.

static class listex {     public static void removefrom<t>(this list<t> lst, int from)     {         lst.removerange(from, lst.count - from);     } } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -