Quantcast
Viewing all articles
Browse latest Browse all 4

Best way to do this?

Welcome to the MSDN Forums.

You can do something like following:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
      string s1 = "99998";
      string s2 = "19";
      string s3 = "9999";
      Console.WriteLine(Do(s1));
      Console.WriteLine(Do(s2));
      Console.WriteLine(Do(s3));
      Console.ReadKey();
    }
    static string Do(string input)
    {
      string temp = input;
      if (temp.Length < 10)
        temp += new string('9', 10 - temp.Length);
      return (temp == "9999999999" ? temp : input);
    }
  }
}

Sincerely,

Yasser.


Don't be stickler and wine with William Shakespeare after the solution :^)
"And this our life, exempt from public haunt, finds tongues in trees, books in the running brooks, sermons in stones, and good in everything." William Shakespeare

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>