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 LastIndexOf Example Syntax - C# LastIndexOf - Sample Code
Description:
Illustrates the C# Syntax for LastIndexOf.
Example Class Main:
using System; public class clsLastIndexOf { public void Main() { //**************************************************************************************** // Example #1: LastIndexOf(string[, startIndex][,count]) // Returns an integer that represents the position of the last 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: LastIndexOf(string[, startIndex][,count]) "); string strLastIndexOfExample = "This is a test string"; Console.WriteLine(strLastIndexOfExample.LastIndexOf("is")); //Returns 5 Console.WriteLine(strLastIndexOfExample.LastIndexOf("xyz")); //Returns -1 //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) { clsLastIndexOf myLastIndexOf = new clsLastIndexOf(); myLastIndexOf.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