OTP code generator C# .Net
Sample C# code to get OTP Code
public static string GenerateOTPCode()
{
char[] charArr = "0123456789".ToCharArray();
string strrandom = string.Empty;
Random objran = new();
var properties = new Properties();
for (int i = 0; i < properties.OTPLength; i++)
{
//It will not allow Repetation of Characters
int pos = objran.Next(1, charArr.Length);
if (!strrandom.Contains(charArr.GetValue(pos).ToString())) strrandom += charArr.GetValue(pos);
else i--;
}
return strrandom;
}