none
Scientific Notation in C# RRS feed

  • Question

  • Hello,

    I wrote this program. Can we write scientific notation in C# without String.Format?

    Thanks in advance

    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace CSharp
    {
        class Class1
        {
            public static void Main()
            {
    
                Console.WriteLine("Number");
                decimal num = Convert.ToDecimal(Console.ReadLine());
    
                string s = string.Format("{0:E2}",num) ;
                Console.WriteLine(s);
                }
            }
        }
    
    

    Sunday, November 3, 2019 6:17 PM

All replies