Converts a digital representation of the renminbi into a capital representation (C # Edition)

Source: Internet
Author: User
Tags bool
Capital | RMB converts the digital representation of the renminbi into capital letters (C # Edition)




There is no good to speak of, is a method, we take it

Using System;

Namespace test.com
{
<summary>
Function: string processing set of functions
</summary>
public class Dealstring
{
#region Private Members
<summary>
Input string
</summary>
private string Inputstring=null;
<summary>
Output string
</summary>
private string Outstring=null;
<summary>
Hint Information
</summary>
private string Notemessage=null;
#endregion

#region Public Properties
<summary>
Input string
</summary>
public string inputstring
{
Get{return inputstring;}
Set{inputstring=value;}
}
<summary>
Output string
</summary>
public string outstring
{
Get{return outstring;}
Set{outstring=value;}
}
<summary>
Hint Information
</summary>
public string Notemessage
{
Get{return Notemessage;}
Set{notemessage=value;}
}
#endregion

#region Constructors
Public dealstring ()
{
//
TODO: Add constructor logic here
//
}
#endregion

#region Public methods
public void Converttochinesenum ()
{
String numlist= "0 A three Woolu qi Ba Nine";
string rmblist = "cent of the points of the million thousand thousand million to pick up hundred thousand million";
Double number=0;
String Tempoutstring=null;

Try
{
Number=double. Parse (this.inputstring);
}
Catch
{
This.notemessage= "Incoming parameter not a number!" ";
Return
}

if (number>9999999999999.99)
This.notemessage= "The value of the people beyond the scope";

Converts a decimal number to an integer string
String Tempnumberstring=convert.toint64 (number*100). ToString ();
int tempnmberlength=tempnumberstring.length;
int i=0;
while (I<tempnmberlength)
{
int Onenumber=int32.parse (tempnumberstring.substring (i,1));
String onenumberchar=numlist.substring (onenumber,1);
String onenumberunit=rmblist.substring (tempnmberlength-i-1,1);
if (onenumberchar!= "0")
Tempoutstring+=onenumberchar+onenumberunit;
Else
{
if (onenumberunit== "billion" | | onenumberunit== "Million" | | onenumberunit== "Yuan" | | onenumberunit== "0")
{
while (Tempoutstring.endswith ("0"))
{
Tempoutstring=tempoutstring.substring (0,tempoutstring.length-1);
}

}
if (onenumberunit== "billion" | | (onenumberunit== "Million" &&!tempoutstring.endswith ("billion")) | | onenumberunit== "Yuan")
{
Tempoutstring+=onenumberunit;
}
Else
{
BOOL Tempend=tempoutstring.endswith ("billion");
BOOL Zeroend=tempoutstring.endswith ("0");
if (tempoutstring.length>1)
{
BOOL Zerostart=tempoutstring.substring (tempoutstring.length-2,2). StartsWith ("0");
if (!zeroend&& (zerostart| |! Tempend))
Tempoutstring+=onenumberchar;
}
Else
{
if (!zeroend&&!tempend)
Tempoutstring+=onenumberchar;
}
}
}
I+=1;
}

while (Tempoutstring.endswith ("0"))
{
Tempoutstring=tempoutstring.substring (0,tempoutstring.length-1);
}

while (Tempoutstring.endswith ("meta"))
{
tempoutstring=tempoutstring+ "whole";
}

this.outstring=tempoutstring;


}
#endregion
}
}



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.