BorislavBorisov

Редици.03.01.How meny times a letter appears in a string

Oct 3rd, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. using System;
  2. class SymbolAppearing
  3. {
  4.     static void Main()
  5.     {
  6.         string text = "Yambol and Vidin are beautiful cities";
  7.         int index = 0, appearance = 0;
  8.         Console.Write("Indexes: ");
  9.         while((index = text.IndexOf('l', index)) != -1)
  10.         {
  11.             Console.Write(index++ + " ");
  12.             appearance++;
  13.         }
  14.         Console.WriteLine();
  15.         Console.WriteLine("Appearance: " + appearance);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment