Advertisement
AmirVagapov

Delete all digits

Apr 2nd, 2023
626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3. class Program {
  4.    /*public static bool IsAllDigits(string s)
  5.     {
  6.         foreach (char c in s)
  7.         {
  8.             if (!char.IsDigit(c))
  9.                 return false;
  10.         }
  11.         return true;
  12.     }*/
  13.  public static int Main() {
  14.      
  15.   Console.Write("Введите строку  : ");
  16.   string S = Console.ReadLine();
  17.   string str = "";
  18.  
  19.     for (int i = 0; i < S.Length; i++)
  20.             {
  21.                 if (!char.IsDigit(S[i]))
  22.                 {
  23.                     str += S[i];
  24.                 } /*else if (IsAllDigits(S)) { str = "only numbers"; }*/
  25.             }
  26.             Console.WriteLine(str);
  27.   Console.ReadKey();
  28.   return 0;
  29.  }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement