Description: The ConvertAll method in the NUnit.Framework library of C# allows us to convert all the elements of a list from one type to another.
Code example 1:
List intList = new List { 1, 2, 3, 4, 5 }; List stringList = intList.ConvertAll(x => x.ToString());
In the above example, we first create a list of integers. Then we use the ConvertAll method to convert the integers to strings and store them in a new list of strings.
Code example 2:
List doubleList = new List { 1.2, 3.4, 5.6 }; List intList = doubleList.ConvertAll(x => Convert.ToInt32(x));
In the above example, we first create a list of doubles. Then we use the ConvertAll method to convert the doubles to integers and store them in a new list of integers.
Package library: NUnit.Framework.
C# (CSharp) NUnit.Framework List.ConvertAll - 30 examples found. These are the top rated real world C# (CSharp) examples of NUnit.Framework.List.ConvertAll extracted from open source projects. You can rate examples to help us improve the quality of examples.