How can I convert Single to integer??

  • Thread starter Thread starter Yasin cepeci
  • Start date Start date
using System;
using System.Collections.Generic;
using System.Text;

namespace SingleToInt
{
class Program
{
static void Main(string[] args)
{
Single s = (Single)1111.87;
int i = (int)s;
Console.WriteLine(i);
Console.ReadLine();
}
}
}

--Peter
 
Yasin cepeci said:
How can I convert Single to integer??

Just cast:

float f = 15.56f;

int x = (int) f;

Be aware that the range of float is much larger than the range of int,
however...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top