Numbers, amounts are converted to Chinese capital, and amounts are converted to Chinese capital

Source: Internet
Author: User

Numbers, amounts are converted to Chinese capital, and amounts are converted to Chinese capital

Public static class NumberToChinese
{
# Convert region values to uppercase values (excluding rounded corners)
/// <Summary>
/// Convert the value to uppercase (without rounded corner points)
/// </Summary>
/// <Param name = "LowerMoney"> </param>
/// <Returns> </returns>
Public static string FloatToChinese (string LowerMoney)
{
String functionReturnValue = null;
Bool IsNegative = false; // whether it is a negative number
If (LowerMoney. Trim (). Substring (0, 1) = "-")
{
// If it is a negative number, convert it to a positive number first.
LowerMoney = LowerMoney. Trim (). Remove (0, 1 );
IsNegative = true;
}
String strLower = null;
String strUpart = null;
String strUpper = null;
Int iTemp = 0;
// Retain two decimal places: 123.489 → 123.49 123.4 → 123.4
LowerMoney = Math. Round (double. Parse (LowerMoney), 2). ToString ();
If (LowerMoney. IndexOf (".")> 0)
{
If (LowerMoney. IndexOf (".") = LowerMoney. Length-2)
{
LowerMoney = LowerMoney + "0 ";
}
}
Else
{
LowerMoney = LowerMoney + ". 00 ";
}
StrLower = LowerMoney;
ITemp = 1;
StrUpper = "";
While (iTemp <= strLower. Length)
{
Switch (strLower. Substring (strLower. Length-iTemp, 1 ))
{
Case ".":
StrUpart = "point ";
Break;
Case "0 ":
StrUpart = "zero ";
Break;
Case "1 ":
StrUpart = "1 ";
Break;
Case "2 ":
StrUpart = "II ";
Break;
Case "3 ":
StrUpart = "";
Break;
Case "4 ":
StrUpart = "Si ";
Break;
Case "5 ":
StrUpart = "Wu ";
Break;
Case "6 ":
StrUpart = "";
Break;
Case "7 ":
StrUpart = "parts ";
Break;
Case "8 ":
StrUpart = "parts ";
Break;
Case "9 ":
StrUpart = "parts ";
Break;
}

Switch (iTemp)
{
Case 1:
StrUpart = strUpart + ""; // minute
Break;
Case 2:
StrUpart = strUpart + ""; //
Break;
Case 3:
StrUpart = strUpart + "";
Break;
Case 4:
StrUpart = strUpart + "";
Break;
Case 5:
StrUpart = strUpart + "pick up ";
Break;
Case 6:
StrUpart = strUpart + "parts ";
Break;
Case 7:
StrUpart = strUpart + "parts ";
Break;
Case 8:
StrUpart = strUpart + "Ten Thousand ";
Break;
Case 9:
StrUpart = strUpart + "pick up ";
Break;
Case 10:
StrUpart = strUpart + "parts ";
Break;
Case 11:
StrUpart = strUpart + "parts ";
Break;
Case 12:
StrUpart = strUpart + "";
Break;
Case 13:
StrUpart = strUpart + "pick up ";
Break;
Case 14:
StrUpart = strUpart + "parts ";
Break;
Case 15:
StrUpart = strUpart + "parts ";
Break;
Case 16:
StrUpart = strUpart + "Ten Thousand ";
Break;
Default:
StrUpart = strUpart + "";
Break;
}

StrUpper = strUpart + strUpper;
ITemp = iTemp + 1;
}

StrUpper = strUpper. Replace ("Zero pick", "zero ");
StrUpper = strUpper. Replace ("zero percent", "zero ");
StrUpper = strUpper. Replace ("zero percent", "zero ");
StrUpper = strUpper. Replace ("zero", "zero ");
StrUpper = strUpper. Replace ("zero", "zero ");
StrUpper = strUpper. Replace ("zero-angle zero-Score", ""); // integer
StrUpper = strUpper. Replace ("0 points", ""); // integer
StrUpper = strUpper. Replace ("", "");
StrUpper = strUpper. Replace ("0 billion 0 thousand", ""); // circle
StrUpper = strUpper. Replace ("0 thousand", ""); // circle
StrUpper = strUpper. Replace ("0 billion 0 thousand", "");
StrUpper = strUpper. Replace ("0 thousand", ""); // circle
StrUpper = strUpper. Replace ("0 billion ");
StrUpper = strUpper. Replace ("0 thousand ");
StrUpper = strUpper. Replace ("", ""); // circle
StrUpper = strUpper. Replace ("zero", "zero ");

If (strUpper. Substring (strUpper. Length-2, 2) = "point zero") // if the last 2 digits is. 0, remove
{
StrUpper = strUpper. Substring (0, strUpper. Length-2 );
}
If (strUpper. Substring (strUpper. Length-1, 1) = "zero") // if the last number is 0, remove
{
StrUpper = strUpper. Substring (0, strUpper. Length-1 );
}
// Processing the amount below the yundun
If (strUpper. Substring (0, 1) = "point") // circle
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}
If (strUpper. Substring (0, 1) = "0 ")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}
// If (strUpper. Substring (0, 1) = "")
//{
// StrUpper = strUpper. Substring (1, strUpper. Length-1 );
//}
// If (strUpper. Substring (0, 1) = "points ")
//{
// StrUpper = strUpper. Substring (1, strUpper. Length-1 );
//}
// If (strUpper. Substring (0, 1) = "integer ")
//{
// StrUpper = "Zero circle ";
//}
FunctionReturnValue = strUpper;

If (IsNegative = true)
{
Return "negative" + functionReturnValue;
}
Else
{
Return functionReturnValue;
}
}

# Convert the endregion value to uppercase (without rounded corner points)

# Convert region amount to capital amount
/// <Summary>
/// Convert the amount to the capital amount
/// </Summary>
/// <Param name = "LowerMoney"> </param>
/// <Returns> </returns>
Public static string MoneyToChinese (string LowerMoney)
{
String functionReturnValue = null;
Bool IsNegative = false; // whether it is a negative number
If (LowerMoney. Trim (). Substring (0, 1) = "-")
{
// If it is a negative number, convert it to a positive number first.
LowerMoney = LowerMoney. Trim (). Remove (0, 1 );
IsNegative = true;
}
String strLower = null;
String strUpart = null;
String strUpper = null;
Int iTemp = 0;
// Retain two decimal places: 123.489 → 123.49 123.4 → 123.4
LowerMoney = Math. Round (double. Parse (LowerMoney), 2). ToString ();
If (LowerMoney. IndexOf (".")> 0)
{
If (LowerMoney. IndexOf (".") = LowerMoney. Length-2)
{
LowerMoney = LowerMoney + "0 ";
}
}
Else
{
LowerMoney = LowerMoney + ". 00 ";
}
StrLower = LowerMoney;
ITemp = 1;
StrUpper = "";
While (iTemp <= strLower. Length)
{
Switch (strLower. Substring (strLower. Length-iTemp, 1 ))
{
Case ".":
StrUpart = "circle ";
Break;
Case "0 ":
StrUpart = "zero ";
Break;
Case "1 ":
StrUpart = "1 ";
Break;
Case "2 ":
StrUpart = "II ";
Break;
Case "3 ":
StrUpart = "";
Break;
Case "4 ":
StrUpart = "Si ";
Break;
Case "5 ":
StrUpart = "Wu ";
Break;
Case "6 ":
StrUpart = "";
Break;
Case "7 ":
StrUpart = "parts ";
Break;
Case "8 ":
StrUpart = "parts ";
Break;
Case "9 ":
StrUpart = "parts ";
Break;
}

Switch (iTemp)
{
Case 1:
StrUpart = strUpart + "points ";
Break;
Case 2:
StrUpart = strUpart + "";
Break;
Case 3:
StrUpart = strUpart + "";
Break;
Case 4:
StrUpart = strUpart + "";
Break;
Case 5:
StrUpart = strUpart + "pick up ";
Break;
Case 6:
StrUpart = strUpart + "parts ";
Break;
Case 7:
StrUpart = strUpart + "parts ";
Break;
Case 8:
StrUpart = strUpart + "Ten Thousand ";
Break;
Case 9:
StrUpart = strUpart + "pick up ";
Break;
Case 10:
StrUpart = strUpart + "parts ";
Break;
Case 11:
StrUpart = strUpart + "parts ";
Break;
Case 12:
StrUpart = strUpart + "";
Break;
Case 13:
StrUpart = strUpart + "pick up ";
Break;
Case 14:
StrUpart = strUpart + "parts ";
Break;
Case 15:
StrUpart = strUpart + "parts ";
Break;
Case 16:
StrUpart = strUpart + "Ten Thousand ";
Break;
Default:
StrUpart = strUpart + "";
Break;
}

StrUpper = strUpart + strUpper;
ITemp = iTemp + 1;
}

StrUpper = strUpper. Replace ("Zero pick", "zero ");
StrUpper = strUpper. Replace ("zero percent", "zero ");
StrUpper = strUpper. Replace ("zero percent", "zero ");
StrUpper = strUpper. Replace ("zero", "zero ");
StrUpper = strUpper. Replace ("zero", "zero ");
StrUpper = strUpper. Replace ("zero-angle zero-point", "whole ");
StrUpper = strUpper. Replace ("0 points", "whole ");
StrUpper = strUpper. Replace ("", "");
StrUpper = strUpper. Replace ("0 billion 0 thousand ");
StrUpper = strUpper. Replace ("0 thousand ");
StrUpper = strUpper. Replace ("0 billion 0 thousand", "");
StrUpper = strUpper. Replace ("0 thousand ");
StrUpper = strUpper. Replace ("0 billion ");
StrUpper = strUpper. Replace ("0 thousand ");
StrUpper = strUpper. Replace ("0 circle", "circle ");
StrUpper = strUpper. Replace ("zero", "zero ");

// Processing the amount below the yundun
If (strUpper. Substring (0, 1) = "circle ")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}
If (strUpper. Substring (0, 1) = "0 ")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}
If (strUpper. Substring (0, 1) = "")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}
If (strUpper. Substring (0, 1) = "points ")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}
If (strUpper. Substring (0, 1) = "integer ")
{
StrUpper = "Zero circle ";
}
FunctionReturnValue = strUpper;

If (IsNegative = true)
{
Return "negative" + functionReturnValue;
}
Else
{
Return functionReturnValue;
}
}

# Convert endregion amount to capital amount
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.