Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication30
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("input yor first split char: ");
- ConsoleKeyInfo usrKey1 = Console.ReadKey();
- Console.WriteLine("input yor second split char: ");
- ConsoleKeyInfo usrKey2 = Console.ReadKey();
- Console.WriteLine();
- Console.WriteLine("input your string: ");
- string str = Console.ReadLine();
- int firstIndex = str.IndexOf(usrKey1.KeyChar) - 1;
- int lastIndex = str.LastIndexOf(usrKey2.KeyChar);
- if (lastIndex == (-1) || firstIndex == (-1))
- Console.WriteLine("this chars is out of string");
- int count = lastIndex - firstIndex;
- Console.WriteLine(count);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement