Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

C Sharp string.IndexOf: Difference between revisions

From Coderwiki
new: info, example
 
(No difference)

Latest revision as of 13:05, 15 August 2025

C Sharp implements the IndexOf method on the string type.

See String position for general information on the usage of this method.

string haystack = "Hello world, C# is a programming language";
string needle = "C#";
int position = haystack.IndexOf(needle);
Console.WriteLine(position);

Output:

13
Contents