달력

122024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
반응형
public string Number2Hangle(long lngNumber)
{
       string[] NumberChar  = new string[] { "", "일", "이", "삼"
                                               , "사", "오", "육"
                                               , "칠", "팔", "구" };
       string[] LevelChar   = new string[] { "", "십", "백", "천" };
       string[] DecimalChar = new string[] { "", "만", "억", "조", "경" };

       string strMinus = string.Empty;

       if (lngNumber < 0)
       {
           strMinus = "마이너스";
           lngNumber *= -1;
       }

       string strValue = string.Format("{0}", lngNumber);
       string NumToKorea = string.Empty;
       bool UseDecimal = false;

       if (lngNumber == 0) return "영";

       for (int i = 0; i < strValue.Length; i++)
       {
           int Level = strValue.Length - i;
           if (strValue.Substring(i, 1) != "0")
           {
               UseDecimal = true;
               if (((Level - 1) % 4) == 0)
               {
                   if(DecimalChar[(Level - 1) / 4] != string.Empty 
                      && strValue.Substring(i, 1) == "1")
                      NumToKorea = NumToKorea + DecimalChar[(Level - 1) / 4];
                   else
                      NumToKorea = NumToKorea 
                                        + NumberChar[int.Parse(strValue.Substring(i, 1))] 
                                        + DecimalChar[(Level - 1) / 4];
                      UseDecimal = false;
               }
               else
               {
                   if (strValue.Substring(i, 1) == "1")
                       NumToKorea = NumToKorea 
                                          + LevelChar[(Level - 1) % 4];
                   else
                       NumToKorea = NumToKorea 
                                          + NumberChar[int.Parse(strValue.Substring(i, 1))] 
                                          + LevelChar[(Level - 1) % 4];
               }
           }
           else
           {
               if ((Level % 4 == 0) && UseDecimal)
               {
                   NumToKorea = NumToKorea + DecimalChar[Level / 4];
                   UseDecimal = false;
               }
           }
       }
       return strMinus + NumToKorea;
   }
}

 

Posted by 유령회사
|