C # tips (1) on Array Conversion
I found that my memory is getting worse and worse now. Just in case you begin to record some tips on C.
Array conversion. This technique is rarely used for our purposes, because this type of data conversion problem is often blocked during interface definition. But it will happen occasionally.
The array. convertall method of c # provides such a conversion. For example, we need to convert an int-type array to a string array. We can write it like this.
Main ()
{
Int [] iarray = {1, 2 };
String [] strarray = array. convertall (iarray, new converter <int, string> (inttostring ));
}
Public static string inttostring (INT argitem)
{
Return argitem. tostring ();
}
In fact, convertall calls the inttostring conversion function through delegation during conversion, and converts the type of each variable in the array.