Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# format string with 2 decimals

// just two decimal places
String.Format("{0:0.00}", 123.4567);      // "123.46"
String.Format("{0:0.00}", 123.4);         // "123.40"
String.Format("{0:0.00}", 123.0);         // "123.00"

Comment

c# format string with 2 decimals

// max. two decimal places
String.Format("{0:0.##}", 123.4567);      // "123.46"
String.Format("{0:0.##}", 123.4);         // "123.4"
String.Format("{0:0.##}", 123.0);         // "123"

Comment

c# format string with 2 decimals

// at least two digits before decimal point
String.Format("{0:00.0}", 123.4567);      // "123.5"
String.Format("{0:00.0}", 23.4567);       // "23.5"
String.Format("{0:00.0}", 3.4567);        // "03.5"
String.Format("{0:00.0}", -3.4567);       // "-03.5"

Comment

PREVIOUS NEXT
Code Example
Csharp :: sort a dictionary by value in c# 
Csharp :: get values from range entity framework 
Csharp :: unity how to add force 
Csharp :: windows form textbox numbers only 
Csharp :: custom editor unity 
Csharp :: phone number regex in c# 
Csharp :: c# change colour of console 
Csharp :: set mouse over colors for button wpf 
Csharp :: wpf set image source in code behind 
Csharp :: website link in unity 
Csharp :: public vs internal c# 
Csharp :: c# 8 null coalescing assignment 
Csharp :: stock span problem c# 
Csharp :: c# determine configration at runtime 
Csharp :: get all assemblies c# 
Csharp :: text not centered winforms button 
Csharp :: c# check if string is directory 
Csharp :: unity how to ommit letters from a string 
Csharp :: oncollisionenter 
Csharp :: blank background for button wpf 
Csharp :: c# sort array of objects by multiple properties 
Csharp :: object list to csv c# 
Csharp :: c#: how to request for admin priviledge 
Csharp :: c# transparent label 
Csharp :: visual studio run multiple forms at once 
Csharp :: convert int to uint c# 
Csharp :: c sharp split string 
Csharp :: c# check if array is empty 
Csharp :: c# thread sleep vs task delay 
Csharp :: The terminal process failed to launch: Path to shell executable "dotnet" is not a file or a symlink. 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =