Click here to Skip to main content
15,945,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to type int with float.
because I have problem with type casting in windows application
while multiplying with int and float numbers.
pls give me a solution.
Posted

you can use Convert function for type casting.

example
float j =5.5;
in i = Convert.ToInt(j);

can you give me your requirement with code?
 
Share this answer
 
If you are dividing int values, you must cast them to doubles if the receiving variable is a double.

For example, this will result in "0":

int x = 1;
int y = 2;
double z = x / y;

Where this will result in the expected 0.5:

int x = 1;
int y = 2;
double z = (double)x / (double)y;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900