Getting digits of number in c# -
i want able take digit number in c# , created function so. used maths digit. here code
static int getdigit(int number, int k) { // k positiong of digit want number // want divide integer number 10....0 (number of 0s k) , % 10 // last digit of new number return (number / (int)math.pow(10, k-1)) % 10; }
however, there error message - "error 1 cannot implicitly convert type 'double' 'int'. explicit conversion exists (are missing cast?)". think math.pow returns double tries convert type of number double. appreciated :)
convert integer?
static int getdigit(int number, int k) { // k positiong of digit want number // want divide integer number 10....0 (number of 0s k) , % 10 // last digit of new number return (int)(number / math.pow(10, k)) % 10; } }
Comments
Post a Comment