Pass multiple types of data arrays through method c# -


i'm creating method loops through each element of array, how can pass any type of data array used in method?

this have @ moment

public void loopthrough(array passed through)         {             for(int x = 0;arr.length;x++)         } 

as in if have int array, char array etc. how can pass them through without having separate method each data type? i.e loopthroughint, loopthroughchar

you use generics:

public void loopthrough<t>(t[] arr) {     (int x = 0; x < arr.length; x++)     {         t t = arr[x];     } } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -