C#人民元換算金額
2081 ワード
///
///
///
///
///
public static string CmycurD(decimal num)
{
string str1 = " "; //0-9
string str2 = " "; //
string str3 = ""; // num
string str4 = ""; //
string str5 = ""; //
int i; //
int j; //num 100
string ch1 = ""; //
string ch2 = ""; //
int nzero = 0; //
int temp; // num
num = Math.Round(Math.Abs(num), 2); // num 2
str4 = ((long)(num * 100)).ToString(); // num 100
j = str4.Length; //
if (j > 15) { return " "; }
str2 = str2.Substring(15 - j); // str2 。 :200.55,j 5 str2=
//
for (i = 0; i = 3)
{
ch1 = "";
ch2 = "";
nzero = nzero + 1;
}
else
{
if (j >= 11)
{
ch1 = "";
nzero = nzero + 1;
}
else
{
ch1 = "";
ch2 = str2.Substring(i, 1);
nzero = nzero + 1;
}
}
}
}
}
if (i == (j - 11) || i == (j - 3))
{
// ,
ch2 = str2.Substring(i, 1);
}
str5 = str5 + ch1 + ch2;
if (i == j - 1 && str3 == "0")
{
// ( ) 0 , “ ”
str5 = str5 + ' ';
}
}
if (num == 0)
{
str5 = " ";
}
return str5;
}
///
/// , CmycurD(decimal num)
///
/// , decimal
///
public static string CmycurD(string numstr)
{
try
{
decimal num = Convert.ToDecimal(numstr);
return CmycurD(num);
}
catch
{
return " !";
}
}