How to separate double into integer and decimal in C#

1 Answer

0 votes
using System;
  
class Program
{
    static void Main() {
        float f = 23.8901f;
          
        var s = f.ToString();
        
        int index = s.IndexOf(".");
          
        Console.WriteLine(s.Substring(0, index));
        Console.WriteLine(s.Substring(index));
    }
}
  
  
  
  
/*
run:
      
23
.8901
      
*/

 



answered Jun 15, 2022 by avibootz

Related questions

1 answer 137 views
1 answer 120 views
1 answer 146 views
146 views asked Nov 16, 2021 by avibootz
1 answer 173 views
3 answers 333 views
3 answers 307 views
...