日期:2014-05-18 浏览次数:20961 次
$num = array( 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六', 7 => '七', 8 => '八', 9 => '九', );
Dictionary<int, string> dic = new Dictionary<int, string>(); dic.Add(1, "一"); dic.Add(2, "二"); dic.Add(3, "三"); dic.Add(4, "四"); dic.Add(5, "五"); dic.Add(6, "六"); dic.Add(7, "七"); dic.Add(8, "八"); dic.Add(9, "九"); dic.Add(10, "十"); 通过 dic.TryGetValue 根据key值得到大写的数字
------解决方案--------------------
string s = @" 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六', 7 => '七', 8 => '八', 9 => '九', "; int n = 3; string result = s.Substring(s.Select((x, i) => new { x, i }).Where(x => x.x - '0' == n).First().i + 6, 1);
------解决方案--------------------
.net 3.5 private static string[] meta = new string[] {"一", "二","三","四","五","六","七","八","九","十"}; public static string Getxxxxxxxx(this int xI,int i) { if(Enumerable.Range(0,10).Contains(i)) { return meta[i]; } return string.Empty; }