NUnit.Framework is a package library for C# used for unit testing. One of its methods is List.IndexOf, which returns the index of the first occurrence of the specified item in the list.
Example 1:
List names = new List{"John", "Peter", "Mary", "Sarah", "John"}; int index = names.IndexOf("John"); // Returns 0
In this example, the List.IndexOf method is used to find the index of the first occurrence of the string "John" in the names list. It returns 0, which is the index of the first "John" in the list.
Example 2:
List numbers = new List{1, 2, 3, 4, 5}; int index = numbers.IndexOf(6); // Returns -1
In this example, the List.IndexOf method is used to find the index of the integer 6 in the numbers list. Since 6 is not in the list, List.IndexOf returns -1.
To use List.IndexOf in C#, you need to include the NUnit.Framework package in your project and import it using the following statement:
using NUnit.Framework;
Once you have imported the package, you can use the List.IndexOf method in your code.
C# (CSharp) NUnit.Framework List.IndexOf - 30 examples found. These are the top rated real world C# (CSharp) examples of NUnit.Framework.List.IndexOf extracted from open source projects. You can rate examples to help us improve the quality of examples.