CSharp examples for System:String Number
Int To Roman Number
using System.Text.RegularExpressions; using System.Text; using System.Security.Cryptography; using System.Linq; using System.Globalization; using System;/*from w w w .j ava 2s . c o m*/ public class Main{ public static string IntToRoman(int num) { string[] thou = { string.Empty, "M", "MM", "MMM" }; string[] hun = { string.Empty, "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" }; string[] ten = { string.Empty, "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" }; string[] ones = { string.Empty, "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" }; string roman = string.Empty; roman += thou[(int)(num / 1000) % 10]; roman += hun[(int)(num / 100) % 10]; roman += ten[(int)(num / 10) % 10]; roman += ones[num % 10]; return roman; } }