Is there any way to "automatically and fast" swap elements with a build-in fast method in a 2dimensional list, array oder dictionary in c#?
edit: to be more specific: i would not just swap 2 elements but change the order of maybe n elements / columns
I have something like this: a 2d datastracture with 10k lines (list with 10k elements) and each of those elements is again a list with 5 elements.(e.g. List of List of String>>).
0 1 2 3 4
0 A B C D E
1 A A A A A
2 d d c k x
3 ...
.
.
10000 ...
Is there any way to swap for all the 10k lines the element / column with index 0 and 2?
At first i would have on line 0: A B C D E and after swap: C B A D E
Or do i have to loop through all lines and swap by myself the element / column with index 0 and 2?
EDIT: In my businesslogic the 2d datastructure is going to be looped line for line and element for element and the values would be inserted somewhere. So my idea is not to loop foreach element, but to loop every line and the elements in a specific order. Since i do not want to access the elements in the order 0,1,2,3,4 but 2,1,0,3,4. Any concerns that accessing listelements in a specific order and not in a foreach manner would be slower? less performant?
edit: there is a link to java Collections.swap http://www.java-examples.com/swap-elements-java-arraylist-example