Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace FirstIndexOf
- {
- class Program
- {
- static void Main(string[] args)
- {
- string source = Console.ReadLine();
- char target = char.Parse(Console.ReadLine());
- Console.WriteLine(FirstIndexOf(source, target));
- }
- public static int FirstIndexOf(string source, char target)
- {
- int targetFirstIndex = -1;
- // Remove the line below then add your implementation.
- for (int i = 0; i < source.Length; i++)
- {
- if (source[i] == target)
- {
- targetFirstIndex = i;
- break;
- }
- }
- return targetFirstIndex;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement