| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Hello World!");
- Console.WriteLine(validateMsisdn("+50935949762"));
- }
- public static String validateMsisdn(String input)
- {
- String CountryCode = "509";
- if (input == null || input.Length == 0)
- {
- return "";
- }
- if (input.StartsWith("+"))
- {
- input = input.Substring(1);
- }
- // check is number
- try
- {
- input = long.Parse(input) + "";
- }
- catch
- {
- return "";
- }
- //
- if (input.StartsWith("0"))
- {
- input = CountryCode + input.Substring(1);
- }
- else if (!input.StartsWith(CountryCode))
- {
- input = CountryCode + input;
- }
- return input.Trim();
- }
- }
- }
|