C implements the method of converting commodity amount from lowercase to uppercase

  • 2021-11-02 02:00:58
  • OfStack

This article illustrates how C # realizes the conversion of commodity amount from lowercase to uppercase. Share it for your reference, as follows:


#region  "Convert the amount of goods from lowercase to uppercase" MoneySmallToBig
/// <summary>
///  Convert item amount from lowercase to uppercase 
/// </summary>
/// <param name="par"> Lowercase amount </param>
/// <returns> Amount in words after processing </returns>
public static string MoneySmallToBig(string par)
{
  String[] Scale = { " Points ", " Angle ", " Yuan ", " Pick up ", " Bai ", " Thousands ", " Ten thousand ", " Pick up ", " Bai ", " Thousands ", " Billion ", " Pick up ", " Bai ", " Thousands ", " Mega ", " Pick up ", " Bai ", " Thousands " };
  String[] Base = { " Zero ", " One ", " 2 ", " 3 ", " Four ", " Wu ", " Land ", " Qi ", " Eight ", " Nine " };
  String Temp = par;
  string result = null;
  int index = Temp.IndexOf(".", 0, Temp.Length);// Determine whether there is a decimal point 
  if (index != -1)
  {
    Temp = Temp.Remove(Temp.IndexOf("."), 1);
    for (int i = Temp.Length; i > 0; i--)
    {
      int Data = Convert.ToInt16(Temp[Temp.Length - i]);
      result += Base[Data - 48];
      result += Scale[i - 1];
    }
  }
  else
  {
    for (int i = Temp.Length; i > 0; i--)
    {
      int Data = Convert.ToInt16(Temp[Temp.Length - i]);
      result += Base[Data - 48];
      result += Scale[i + 1];
    }
  }
  return result;
}
#endregion

PS: Here is another conversion tool for your reference:

Online conversion tool for RMB capitalization:
http://tools.ofstack.com/zhuanhuanqi/rmbupper

More readers interested in C # can check the topic of this site: "C # Form Operation Skills Summary", "C # Common Control Usage Tutorial", "WinForm Control Usage Summary", "C # Programming Thread Use Skills Summary", "C # Operating Excel Skills Summary", "XML File Operation Skills Summary in C #", "C # Data Structure and Algorithm Tutorial", "C # Array Operation Skills Summary" and "C # Object-Oriented Programming Introduction Tutorial"

I hope this article is helpful to everyone's C # programming.


Related articles: