Programming
Python
R
Java
C
C++
C#
WEB
HTML
CSS
JavaScript
BootStrap4
jQuery
SVG
MORE
Examples1
Python
GO
R
Java
C
C++
C#
Examples2
Python
R
Java
C
C++
C#
HTML
CSS
JavaScript
BootStrap4
jQuery
SVG
Seo Tools
Code Minifier
Code Beautifier
Language Compiler
Misc Tools
File Converter
References
C
C++
Python
Java
PHP
JavaScript
Examples
Python
R
Java
C
C++
C#
HTML
CSS
JavaScript
BootStrap4
jQuery
SVG
Home
About
Contact
JetPack
Multi Themes-->>
Code it ALL
Scroll TOP
IndexOf() in C# - CodeGK
Δ Cs Examples
Arrays
Declaring an Array in C#
Initializing an Array in C#
Char
Char in C#
Finding ascii value of Char in C#
Strings
Strings in C#
String Concatenation in C#
String Length in C#
ToLower() in C#
ToUpper() in C#
Interpolation of Strings in C#
IndexOf() in C#
Substring in C#
Int
Int in C#
Int Operations in C#
Switch
Switch in C#
Booleans
Booleans in C#
Operations on Booleans in C#
If_else
If in C#
Else in C#
Else-If in C#
Float
float in C#
float operations in C#
Comments
Single-Line comments in C#
Multi-Line comments in C#
Double
Double in C#
Operations on Double in C#
Long
Long in C#
Operations on Long in C#
Variables
Global Variable in C#
Local Variable in C#
♦ IndexOf() in C#
♣ Example7: IndexOf() in C#
IndexOf() is a string method that finds the index of given character.
In this example, IndexOf() is illustrated.
Example
Input:
Run CODE
Reload Code
Copy Code
using System; namespace Strings { class Program { static void Main(string[] args) { string s1="spaceX"; string s2="Ratchet"; int s3=s1.IndexOf('X'); Console.WriteLine(s3); int s4=s2.IndexOf('t'); Console.WriteLine(s4); } } }
Output:
Strings
IndexOf() in C#