Converting


To Another Array

It is possible to implicitly convert from an array of one reference type to an array of another reference type
The arrays are convertible as long as their ranks are the same.


This is possible because System.String derives from System.Object

System.String[] places = new string[4]; 
System.Object[] objects = places; //implicit conversion

Going the other way requires an explicit conversion

System.String[] moreplaces = (string[]) objects  //explicit conversion 

To Comma Delimited String


string[] places = new string[3]; 
places[0] = "london";
places[1] = "new york";
places[2] = "tokyo";
string concat = System.String.Join(",",places);

To ArrayList

arraylist = new System.Collections.ArrayList; 
arraylist.addrange(array);


To List

System.Collections.Generic.List<string> oList; 
oList = new System.Collections.Generic.List<string>();
string[] array
oList.AddRange(array);




© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext