0

I'm new to c# so this is probably a stupid question. If I write

double d = 2175 / 405;

d is always 5, ie there is never the decimal part. If I do the same in vb.net then I get the answer I expect. Appreciate any assistance.

  • There's probably a C# version somewhere such that this should be marked as a duplicate, but see e.g. http://stackoverflow.com/questions/7571326/why-cant-i-return-a-double-from-two-ints-being-divided?rq=1 (exsum: int/int is int; if you want double, do 2175 / 405.0 or 2175 / (double) 405. – Foon Jan 14 '17 at 17:50
  • Thanks Foon that solved it for me – alungwyther Jan 15 '17 at 11:25

0 Answers0