Advertisement
Gillito

Untitled

Jun 4th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication30
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("input yor first split char: ");
  14.             ConsoleKeyInfo usrKey1 = Console.ReadKey();
  15.             Console.WriteLine("input yor second split char: ");
  16.             ConsoleKeyInfo usrKey2 = Console.ReadKey();
  17.             Console.WriteLine();
  18.            
  19.             int count = 0;
  20.             Console.WriteLine("input your string: ");
  21.             string str = Console.ReadLine();
  22.  
  23.             count = str.LastIndexOf(usrKey2.KeyChar) - str.IndexOf(usrKey1.KeyChar) - 1;
  24.             if (str.LastIndexOf(usrKey2.KeyChar) == (-1) || str.IndexOf(usrKey1.KeyChar) == (-1))
  25.                 Console.WriteLine("this chars is out of string");
  26.             //for (int i = str.IndexOf(usrKey1.KeyChar) + 1; i < str.LastIndexOf(usrKey2.KeyChar); i++)
  27.             //    count++;
  28.             Console.WriteLine(count);
  29.             Console.ReadLine();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement