Advertisement
Guest User

rie

a guest
Jan 24th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Console.WriteLine("Give a text");
  2. string text = Console.ReadLine();
  3.  
  4. Console.WriteLine("Give a substring");
  5. string subStr=Console.ReadLine();
  6.  
  7. int subSum = text.IndexOf(subStr, StringComparison.OrdinalIgnoreCase);
  8. int count = 0;
  9. for (int i = 0; i < text.Length; i++)
  10. {
  11. if (subSum >= 0)
  12. {
  13. subSum = text.IndexOf(subStr, subSum + 1, StringComparison.OrdinalIgnoreCase);
  14. Console.WriteLine(subSum);
  15. count++;
  16. }
  17. }
  18.  
  19. Console.WriteLine(count);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement