Answers for "string.indexof c# return value"

C#
4

c sharp index of substring

// To find the index of the first substring in a string use
// 'IndexOf()'
string str = "Hello World!"
str.IndexOf("o"); // Output: 4

// You can give a starting index and a length to search at
str.IndexOf("o", 6, 4); // Output: 7

// To find the last instance of a substring use 'LastIndexOf()'
str.LastIndexOf("o"); // Output: 7
Posted by: Guest on February-26-2020
-1

strinng.indexOf c#

int index = String.IndexOf(char x);
int index = String.IndexOf(string x);
Posted by: Guest on November-24-2020

C# Answers by Framework

Browse Popular Code Answers by Language