本文整理匯總了C#中System.Globalization.IdnMapping.GetHashCode方法的典型用法代碼示例。如果您正苦於以下問題:C# IdnMapping.GetHashCode方法的具體用法?C# IdnMapping.GetHashCode怎麽用?C# IdnMapping.GetHashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Globalization.IdnMapping
的用法示例。
在下文中一共展示了IdnMapping.GetHashCode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
string email = "johann_doe@bücher.com john_doe@hotmail.com иван@мойдомен.рф";
IdnMapping idn = new IdnMapping();
int start = 0, end = 0;
while (end >= 0) {
start = email.IndexOf("@", end);
end = email.IndexOf(" ", start);
string domain = String.Empty;
try {
string punyCode = String.Empty;
if (start >= 0 && end >= 0) {
domain = email.Substring(start + 1, end - start - 1);
punyCode = idn.GetAscii(email, start + 1, end - start - 1);
}
else {
domain = email.Substring(start + 1);
punyCode = idn.GetAscii(email, start + 1);
}
string name2 = idn.GetUnicode(punyCode);
Console.WriteLine("{0} --> {1} --> {2}", domain, punyCode, name2);
}
catch (ArgumentException) {
Console.WriteLine("{0} is not a valid domain name.", domain);
}
Console.WriteLine();
}
}
}
輸出:
bücher.com --> xn--bcher-kva.com --> bücher.com hotmail.com --> hotmail.com --> hotmail.com мойдомен.рф --> xn--d1acklchcc.xn--p1ai --> мойдомен.рф