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 235 views
1 answer 224 views
1 answer 262 views
262 views asked Nov 16, 2021 by avibootz
1 answer 310 views
3 answers 536 views
3 answers 504 views
...