C# String LastIndexOf(Char)

Description

String LastIndexOf(Char) reports the zero-based index position of the last occurrence of a specified Unicode character within this instance.

Syntax

String.LastIndexOf(Char) has the following syntax.


public int LastIndexOf(
  char value
)

Parameters

String.LastIndexOf(Char) has the following parameters.

  • value - The Unicode character to seek.

Returns

String.LastIndexOf(Char) method returns The zero-based index position of value if that character is found, or -1 if it is not.

Example

The following example uses the LastIndexOf(Char) method.


/*from w ww  .ja  va 2s  . c o m*/
using System;
using System.IO;

public class TestLastIndexOf
{
   public static void Main()
   {
      Console.WriteLine(@"C:\temp\".LastIndexOf('\\'));
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version