CSharp examples for Language Basics:int
Get the 2-digit string representation of an integer in [1,99]
using System.Text; using System.Linq; using System.Collections.Generic; using System;//from w w w . j a v a 2 s. c o m public class Main{ /// <summary> /// Get the 2-digit string representation of an integer in [1,99] /// </summary> /// <param name="num"></param> /// <returns></returns> public static string GetTwoDigitString(int num) { if (num < 1 || num >= 100) return null; if (num < 10) return "0" + num.ToString(); else return num.ToString(); } }