What are conversion operators?

Conversion operators convert the type of input objects into a specific type or sequence. The aggregate operators are AsEnumerable, Cast, ToList, ToArray and ToDictionary.

List < int > data = new List < int > {
	10, 20, 30, 40, 50
};
//Cast to Array
int[] strArray = data.Cast < int > ().ToArray(); //result:10 20 30 40 50
for (int i = 0; i < strArray.Length; i++) {
	Console.Write(strArray[i] + " ");
}

 

Tagged , . Bookmark the permalink.

Leave a Reply