Table of Contents
- OtpCode
- Properties
- Constructors
- OtpCode(Int32, Int32)
- OtpCode(Int32, Int32, Nullable<DateTimeOffset>)
- OtpCode(String)
- OtpCode(String, Nullable<DateTimeOffset>)
- Methods
OtpCode
Namespace: SimpleOTP
Represents a one-time password (OTP) code.
public struct OtpCode
Inheritance Object → ValueType → OtpCode
Implements IEquatable<OtpCode>, IEquatable<String>, IXmlSerializable
Attributes SerializableAttribute, NullableContextAttribute, NullableAttribute, IsReadOnlyAttribute, JsonConverterAttribute
Properties
CanExpire
Gets a value indicating whether the OTP code can expire (true for TOTP, false for HOTP).
public bool CanExpire { get; }
Property Value
ExpirationTime
Gets the expiration time of the OTP code (TOTP only).
public Nullable<DateTimeOffset> ExpirationTime { get; }
Property Value
Constructors
OtpCode(Int32, Int32)
Initializes a new instance of the OtpCode struct with the specified value with no expiration time.
OtpCode(int code, int digits)
Parameters
code Int32
The value of the OTP code.
digits Int32
The number of digits in the OTP code.
Exceptions
ArgumentNullException
code is .
ArgumentException
code is not a valid numeric code.
OtpCode(Int32, Int32, Nullable<DateTimeOffset>)
Initializes a new instance of the OtpCode struct with the specified value and the expiration time.
OtpCode(int code, int digits, Nullable<DateTimeOffset> expirationTime)
Parameters
code Int32
The value of the OTP code.
digits Int32
The number of digits in the OTP code.
expirationTime Nullable<DateTimeOffset>
The expiration time of the OTP code (TOTP only).
Exceptions
ArgumentNullException
code is .
ArgumentException
code is not a valid numeric code.
OtpCode(String)
Initializes a new instance of the OtpCode struct with the specified value with no expiration time.
OtpCode(string code)
Parameters
code String
The value of the OTP code.
Exceptions
ArgumentNullException
code is .
ArgumentException
code is not a valid numeric code.
OtpCode(String, Nullable<DateTimeOffset>)
Initializes a new instance of the OtpCode struct with the specified value and the expiration time.
OtpCode(string code, Nullable<DateTimeOffset> expirationTime)
Parameters
code String
The value of the OTP code.
expirationTime Nullable<DateTimeOffset>
The expiration time of the OTP code (TOTP only).
Exceptions
ArgumentNullException
code is .
ArgumentException
code is not a valid numeric code.
Methods
ToString()
Returns a string representation of the OTP code.
string ToString()
Returns
String
A string representation of the OTP code.
ToString(String)
Returns a string representation of the OTP code.
string ToString(string format)
Parameters
format String
The format to use.
Returns
String
The string representation of the OTP code.
Equals(OtpCode)
bool Equals(OtpCode other)
Parameters
other OtpCode
Returns
Equals(Object)
bool Equals(object obj)
Parameters
obj Object
Returns
Equals(String)
bool Equals(string other)
Parameters
other String
Returns
GetHashCode()
int GetHashCode()
Returns
GetSchema()
XmlSchema GetSchema()
Returns
XmlSchema
ReadXml(XmlReader)
void ReadXml(XmlReader reader)
Parameters
reader XmlReader
WriteXml(XmlWriter)
void WriteXml(XmlWriter writer)
Parameters
writer XmlWriter
Parse(String)
Parses the specified String into an OtpCode object.
OtpCode Parse(string code)
Parameters
code String
The string to parse.
Returns
Exceptions
ArgumentNullException
code is .
ArgumentException
code is not a valid numeric code.
TryParse(String, OtpCode&)
Tries to parse the specified String into an OtpCode object.
bool TryParse(string code, OtpCode& result)
Parameters
code String
The string to parse.
result OtpCode&
The parsed OtpCode object.
Returns
Boolean
if code was parsed successfully; otherwise, .
©2025 Eugene Fox. Licensed under MIT license