+ 1

Using "Double" for Thread.Sleep()

Hello Friends, my question is if it is possible to somehow change the type of variable "v" from INT to DOUBLE for example? I've tried several not really clever ways, but it feels i'm too young in it to understand. So i need your Help! :) public static void Sleep(int v) { const int a = 500; Thread.Sleep(a * v); }

7th Feb 2017, 5:03 PM
Igor Ilnicky
Igor Ilnicky - avatar
2 Answers
+ 1
you could cast from double to int after multiplying, public static void Sleep(double v) { const int a = 500; Thread.Sleep((int)(a * v)); } You could also round it, as casting to int truncates.
7th Feb 2017, 5:20 PM
Ugnius Soraka
+ 1
Great, thank you so much! :)
7th Feb 2017, 5:45 PM
Igor Ilnicky
Igor Ilnicky - avatar