1. Converting a string array to an int array
string[] input = {"1","2","3","4","5","6","7","8","9" };int[] output = array.convertall<string,int> (Input,Delegate(strings) {return int. Parse (s); });
Attention:
Use the static generic method ConvertAll in the array class to convert.
Delegate (string s) {return int. Parse (s); This sentence means: Establish an anonymous delegate, the method body associated with the delegate is: return int. Parse (s); Casts each string in the array to reshape and returns the add to output.
2. Sorting
Method One: Use the sort () method of ArrayList
usingSystem.Collections;int[] arr = {2,4,5,6,6, -, the, the, the,669,569 }; ArrayList List=NewArrayList (arr); list. Sort ();intmin = Convert.ToInt32 (list[0]);intmax = Convert.ToInt32 (list[list. Count-1]); Console.WriteLine ("Maximum"+ Max +"Minimum:"+min);
Method Two: (If the values in the array are less than a, this does not apply)
int a=0; b=0; for (int i=0; i<array.length;i++) { a>a[i]? ( B=A):(b=a[i]), as long as the round for loop can derive the maximum value, the same as the minimum value.}
C # Converts a string array to an int array and gets the maximum minimum value