Pad number with zero - CSharp System

CSharp examples for System:DateTime Format

Description

Pad number with zero

Demo Code


using System.Text;
using System;/*from  www.ja  va  2 s .c  o  m*/

public class Main{
        /// <summary>
        /// Pad number with zero
        /// </summary>
        /// <param name="number">Number to pad</param>
        /// <returns>Padded number</returns>
        private static string padZero(int number)
        {
            return (number > 9) ? "" + number : "0" + number;
        }
}

Related Tutorials