Wednesday, September 23, 2009

Simple Recursive example C#

#purpose : method to get the decimal position based on passed number

private static int GetDividebyValue(int dec_position)
{
return ((dec_position == 1) ? 1 : (10 * GetDividebyValue(dec_position - 1)));
}


//calling method

int dividby = GetDividebyValue(decimal_position+1);

No comments: