Progress Monitor for IdealProgrammer.com
Take Swift, Intelligent, Massive, Planned, Loving, Effective (S.I.M.P.L.E.) Action to Transform Self into Ideal
Skip Repetitive Navigational Links
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console
Please login
C-Sharp IndexOf Example - IndexOf - Sample Code
Description:
Illustrates the C# Syntax for IndexOf.
Example Class Main:
using System; public class clsIndexOf { public void Main() { //**************************************************************************************** // Example #1: IndexOf(string[, startIndex][,count]) // Returns an integer that represents the position of the first occurrence of the // specified number of characters. If you specify startIndex, that specifies // where to start looking. If you specify count, that specifies how many characters to // to search past start. If the string is not found, this method returns -1 //**************************************************************************************** Console.WriteLine("Example #1: IndexOf(string[, startIndex][,count]) "); string strIndexOfExample = "This is a test string"; Console.WriteLine(strIndexOfExample.IndexOf("is")); //Returns 2 Console.WriteLine(strIndexOfExample.IndexOf("xyz")); //Returns -1 (not found) //write blank line to make output easier to read Console.WriteLine(); //Prevent console from closing before you press enter Console.ReadLine(); } }
Example Class Program:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CSharp_Syntax { class Program { static void Main(string[] args) { clsIndexOf myIndexOf = new clsIndexOf(); myIndexOf.Main(); } } }
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console