csharp float to string with 2 decimals

Code Example - csharp float to string with 2 decimals

                
                        myFloatVariable.ToString("0.00"); //2dp Number

myFloatVariable.ToString("n2"); // 2dp Number

myFloatVariable.ToString("c2"); // 2dp currency
                    
                
 

csharp type cast float to string

                        
                                float number = 123;
String str_One = number.ToString();

By: Barry Cox