C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# String LastIndexOfAny()The C# LastIndexOfAny() method is used to find index position of the last occurrence of one or more characters specified in this string. Signaturepublic int LastIndexOfAny(Char[] ch) public int LastIndexOfAny(Char[], Int32) public int LastIndexOfAny(Char[], Int32, Int32) Parameterch: it is a character type array. ReturnIt returns integer value. C# String LastIndexOfAny() Method Exampleusing System; public class StringExample { public static void Main(string[] args) { string s1 = "abracadabra"; char[] ch = {'r','b'}; int index = s1.LastIndexOfAny(ch);//Finds 'r' at the last Console.WriteLine(index); } } Output: 9 C# String LastIndexOfAny() Method Example 2using System; public class StringExample { public static void Main(string[] args) { string s1 = "abracadabra"; char[] ch = {'t','b'}; int index = s1.LastIndexOfAny(ch);//Finds 'b' at the last Console.WriteLine(index); } } Output: 8
Next TopicC# String PadLeft()
|