Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# int ToString format on 2 char int?

Tags:

c#

tostring

How do I use the ToString method on an integer to display a 2-char

int i = 1; i.ToString() -> "01" instead of "1"

Thanks.

like image 480
Ray Avatar asked Feb 14 '12 17:02

Ray


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C full form?

Originally Answered: What is the full form of C ? C - Compiler . C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC PDP-11 computer in 1972.

How old is the letter C?

The letter c was applied by French orthographists in the 12th century to represent the sound ts in English, and this sound developed into the simpler sibilant s.

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.


1 Answers

You can use i.ToString("D2") or i.ToString("00")

See Standard Numeric Format Strings and Custom Numeric Format Strings on Microsoft Docs for more details

like image 84
Patrick McDonald Avatar answered Sep 20 '22 07:09

Patrick McDonald