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 ConsoleApp20
- {
- class Program
- {
- //delegate int Howdy(char symbol, string text);
- static void Main(string[] args)
- {
- Func<char, string, int> GetValue;
- GetValue = HowManySymbols;
- GetValue += IndexOfFirst;
- string text = Console.ReadLine();
- char symbol = char.Parse(Console.ReadLine());
- //Howdy howdy = HowManySymbols;
- //howdy += IndexOfFirst;
- //howdy.Invoke(symbol, text);
- GetValue.Invoke(symbol, text);
- }
- static int HowManySymbols(char symbol, string text)
- {
- int count = 0;
- foreach (var letter in text)
- {
- if (letter == symbol)
- count++;
- }
- return count;
- }
- static int IndexOfFirst(char symbol, string text)
- {
- for (int i = 0; i<text.Length; i++)
- {
- if (text[i] == symbol)
- return i;
- }
- return -1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement