Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApp14
- {
- static class SuperString
- {
- public static string Odwroc(this string input)
- {
- char[] temp;
- temp = input.ToCharArray();
- Array.Reverse(temp);
- return new string(temp);
- }
- public static string Ile(this string input, char a)
- {
- int counter=0;
- foreach (char b in input)
- {
- if (b == a)
- {
- counter++;
- }
- }
- return $"W podanym tekscie znajduje się {counter} szukanych znaków. ";
- }
- public static string Skroc(this string input, int n)
- {
- string temp = "";
- for (int i = 0; i < n-(n/2); i++)
- {
- temp += input[i];
- }
- for (int i = input.Length-(n/2); i <input.Length ; i++)
- {
- temp += input[i];
- }
- return temp;
- }
- public static string Usun(this string input, string t)
- {
- string temp= input.Replace(t, "");
- return temp;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- string s = "onyTelefony";
- Console.WriteLine(s.Odwroc());
- Console.WriteLine(s.Ile('e'));
- Console.WriteLine(s.Skroc(4));
- Console.WriteLine(s.Usun("ony"));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement