Not sure where I got this, so my apologies to the original author, but it's been a pretty useful function. Of course, you might want to wrap this with some error handling and validation code, but here's a good start for you...
private string GetRomanNumber(int number)
{ string[] ArabicNums = new string[] {"1", "4", "5", "9", "10", "40", "50", "90", "100", "400", "500", "900", "1000"}; string[] RomanNums = new string[] {"I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"};
int ArabicUpper = ArabicNums.GetUpperBound(0);
int ArabicLower = ArabicNums.GetLowerBound(0);
string Output = "";
for (int i = ArabicUpper; i >= ArabicLower; i--)
{ while (number >= Convert.ToInt32(ArabicNums[i]))
{ number -= Convert.ToInt32(ArabicNums[i]);
Output += RomanNums[i];
}
}
return Output;
}
Enjoy!