Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# i lose 0 when converting int to string

int myNumber = 010;
string myString = myNumber.ToString("D3");
Console.Write(myString);

/* D represents 'Decimal', and 3 is the specified amount of digits you want
   the number to always be. This will pad your value with zeroes until it 
   reaches 5 digits.*/
Comment

translate int to string with x 0 before c#

using System;
					
public class Program
{
	public static void Main()
	{
		int num = 50;
		string paddedNum = num.ToString().PadLeft(5, '0');
		
		Console.WriteLine(paddedNum);
	}
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: How to create a Blazor server-side application in command prompt 
Csharp :: monogame button 
Csharp :: unity DOScale 
Csharp :: c# substring find word 
Csharp :: C# top down view player movement 
Csharp :: c# calculate checksum of file 
Csharp :: linq select max value from list 
Csharp :: c# convert string to datetime dd-mm-yyyy hh-mm-ss 
Csharp :: Merge two List using Linq 
Csharp :: linear search algorithm c# 
Csharp :: Send Hotmail, Outlook, Office365 Email using SMTP C# .NET 
Csharp :: stop playing audiosource 
Csharp :: C# http post request with file 
Csharp :: bind repeater to dictionary 
Csharp :: c# signalr console app server example 
Csharp :: c# get executing file name 
Csharp :: caesar cipher in C# 
Csharp :: write last line txt file c# 
Csharp :: c# webbrowser write html to text file 
Csharp :: c# get all occurrences of a string 
Csharp :: how to insert data into multiple tables using asp.net c# 
Csharp :: linq select to list 
Csharp :: unity play animation on click 
Csharp :: Using Linq to get the last N elements of a collection? C# 
Csharp :: static initializer 
Csharp :: Transpose Matrix C# 
Csharp :: how to filter a list in c# 
Csharp :: overridable method C# 
Csharp :: c# int to short 
Csharp :: dadar pincode 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =