1staticstringConvertToKansuji(int n)=>string.Concat(EnumerateDigits(n).Select(i =>ToKansujiOnBaseByString(i)).Reverse());2staticstringConvertToKansuji(string str,bool onlyDigits =false)=>string.Concat(str.ToCharArray().Where(c =>!onlyDigits ||char.IsDigit(c)).Select(c =>char.IsDigit(c)?ToKansujiOnBaseByDictionary(c):$"{c}"));3staticIEnumerable<int>EnumerateDigits(int n,int unit =10)4{5while(n >= unit)6{7yieldreturn n % unit;8 n = n / unit;9}10}11staticstringToKansujiOnBaseByString(int n,int unit =10)=> unit >10|| n >= unit ?thrownewInvalidOperationException("illegal"):$"{"〇一二三四五六七八九"[n]}";12staticstringToKansujiOnBaseByArray(int n,int unit =10)=> unit >10|| n >= unit ?thrownewInvalidOperationException("illegal"):(new[]{"〇","一","二","三","四","五","六","七","八","九",})[n];13staticstringToKansujiOnBaseByDictionary(char n,int unit =10)=> unit >10||!char.IsDigit(n)||(int)char.GetNumericValue(n)>= unit ?thrownewInvalidOperationException("illegal"):(newDictionary<char,string>{{'0',"〇"},{'1',"一"},{'2',"二"},{'3',"三"},{'4',"四"},{'5',"五"},{'6',"六"},{'7',"七"},{'8',"八"},{'9',"九"},})[n];