elena1234

Telephony - how to work with string and char

Apr 5th, 2021 (edited)
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Telephony
  5. {
  6.     public class Smartphone : ICallable, IBrowsable
  7.     {
  8.         public string CallOtherPhone(string Number)
  9.         {
  10.             if (!Number.All(ch => char.IsDigit(ch)))
  11.             {
  12.                 throw new ArgumentException("Invalid number!");
  13.             }
  14.  
  15.             return $"Calling... {Number}";
  16.         }
  17.  
  18.         public string BrowseInWeb(string URL)
  19.         {
  20.             if (URL.Any(ch => char.IsDigit(ch)))
  21.             {
  22.                 throw new ArgumentException("Invalid URL!");
  23.             }
  24.  
  25.             return $"Browsing:  {URL}";
  26.         }
  27.     }
  28. }
  29.  
Add Comment
Please, Sign In to add comment