本文整理汇总了C#中Randomizer.Replace方法的典型用法代码示例。如果您正苦于以下问题:C# Randomizer.Replace方法的具体用法?C# Randomizer.Replace怎么用?C# Randomizer.Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Randomizer
的用法示例。
在下文中一共展示了Randomizer.Replace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cpr
public static string Cpr(this Person p)
{
const string Key = nameof(ExtensionsForDenmark) + "CPR";
if (p.context.ContainsKey(Key))
{
return p.context[Key] as string;
}
var r = new Randomizer();
var final = $"{p.DateOfBirth:ddMMyy}-{r.Replace("####")}";
p.context[Key] = final;
return final;
}
示例2: nameof
public static string Henkilötunnus(this Person p)
{
const string Key = nameof(ExtensionsForFinland) + "Henkilötunnus";
if (p.context.ContainsKey(Key))
{
return p.context[Key] as string;
}
// DDMMYYCZZZQ
//
// DD
// MM
// YY - DOB
// C - Centry
// ZZZ odd for males, even for females
// Q = The control character is calculated as the remainder of DDMMYYZZZ
// divided by 31, i.e. drop the century sign and divide the resulting nine
// digit number by 31. For remainders below ten, the remainder itself is
// the control character, otherwise pick the corresponding character from
// string "0123456789ABCDEFHJKLMNPRSTUVWXY". For example, 311280888 divided by 31
// gives the remainder as 30, and since A=10, B=11, etc. ending up with Y=30.
var r = new Randomizer();
var year = p.DateOfBirth.Year;
var c = "A";
if( year >= 1800 && year <= 1899 )
c = "+";
else if( year >= 1900 && year <= 1999 )
c = "-";
var ddMMyy = $"{p.DateOfBirth:ddMMyy}";
var n = int.Parse(ddMMyy) % 31;
var q = n.ToString();
if( n > 10 )
q = ((char)('A' + (n - 10))).ToString();
//no idea if its female or male.
var zzz = r.Replace("###");
var final = $"{ddMMyy}{c}{zzz}{q}";
p.context[Key] = final;
return final;
}