IndexOf keyword in .NET

IndexOf is an extension method (default functionality can be overridden) on string.
Method will return index number of a character position in string.

Take a look in this example

public static void Main()
 {
  var character = "ABS";
  Console.WriteLine(character.IndexOf("B"));
 }

We are expecting to see 1 in Console.

If character does not exist in the string method will return -1.


public static void Main()
 {
  var character = "ABS";
  Console.WriteLine(character.IndexOf("F"));
 }

Above method will return -1.


Comments

  1. This is the first & best article to make me satisfied by presenting good content. I feel so happy and delighted.By Learn Digital Marketing Course Training in Chennai it will help to get Digital Marketing Course Training with Placement Institute in Chennai. If you Learn Social Media Marketing Training with Placement Institute in Chennai, you will get job soon.

    Learn Best Digital Marketing Course Training in Chennai in professional institute to get reputed job.

    ReplyDelete

Post a Comment