ProgrammingLanguage
Hashtable ht = new Hashtable();
if (!ht.Contains(_selstchf.Table.Rows[i]["rank"].ToString())) //ๆ้ค้่ค่ณๆ
{
rankCount++;
ht.Add(_selstchf.Table.Rows[i]["rank"].ToString(), _selstchf.Table.Rows[i]["rank"].ToString());
}
โpublic static string NumberToText(int number, bool isUK)
โโโโ{
โโโโ if (number == 0)
โโโโ return "Zero";
โโโโ string and = isUK ? "and " : ""; // deals with UK or US numbering
โโโโ
โโโโ if (number == -2147483648)
โโโโ return "Minus Two Billion One Hundred " + and +
โโโโ "Forty Seven Million Four Hundred " + and + "Eighty Three Thousand " +
โโโโ "Six Hundred " + and + "Forty Eight";
โโโโ
โโโโ int[] num = new int[4];
โโโโ int first = 0;
โโโโ int u, h, t;
โโโโ System.Text.StringBuilder sb = new System.Text.StringBuilder();
โโโโ
โโโโ if (number < 0)
โโโโ {
โโโโ sb.Append("Minus ");
โโโโ number = -number;
โโโโ }
โโโโ string[] words0 = { "", "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine " };
โโโโ string[] words1 = { "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen " };
โโโโ string[] words2 = { "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety " };
โโโโ string[] words3 = { "Thousand ", "Million ", "Billion " };
โโโโ num[0] = number % 1000; // units
โโโโ num[1] = number / 1000;
โโโโ num[2] = number / 1000000;
โโโโ num[1] = num[1] - 1000 * num[2]; // thousands
โโโโ num[3] = number / 1000000000; // billions
โโโโ num[2] = num[2] - 1000 * num[3]; // millions
โโโโ
โโโโ for (int i = 3; i > 0; i--)
โโโโ {
โโโโ if (num[i] != 0)
โโโโ {
โโโโ first = i;
โโโโ break;
โโโโ }
โโโโ }
โโโโ
โโโโ for (int i = first; i >= 0; i--)
โโโโ {
โโโโ if (num[i] == 0) continue;
โโโโ u = num[i] % 10; // ones
โโโโ t = num[i] / 10;
โโโโ h = num[i] / 100; // hundreds
โโโโ t = t - 10 * h; // tens
โโโโ if (h > 0) sb.Append(words0[h] + "Hundred ");
โโโโ if (u > 0 || t > 0)
โโโโ {
โโโโ if (h > 0 || i < first) sb.Append(and);
โโโโ if (t == 0)
โโโโ sb.Append(words0[u]);
โโโโ else if (t == 1)
โโโโ sb.Append(words1[u]);
โโโโ else
โโโโ sb.Append(words2[t - 2] + words0[u]);
โโโโ }
โโโโ if (i != 0) sb.Append(words3[i - 1]);
โโโโ }
โโโโ return sb.ToString().TrimEnd();
โโโโ}
MessageBoxButtons