Parity 枚举

定义

``public enum class Parity``
``public enum Parity``
``type Parity = ``
``Public Enum Parity``

Parity

字段

 Even 2 设置奇偶校验位，使位数等于偶数。Sets the parity bit so that the count of bits set is an even number. Mark 3 将奇偶校验位保留为 1。Leaves the parity bit set to 1. None 0 不发生奇偶校验检查。No parity check occurs. Odd 1 设置奇偶校验位，使位数等于奇数。Sets the parity bit so that the count of bits set is an odd number. Space 4 将奇偶校验位保留为 0。Leaves the parity bit set to 0.

示例

``````static Parity SetPortParity(Parity defaultPortParity)
{
String^ parity;

Console::WriteLine("Available Parity options:");
for each (String^ s in Enum::GetNames(Parity::typeid))
{
Console::WriteLine("   {0}", s);
}

Console::Write("Enter Parity value (Default: {0}):", defaultPortParity.ToString());

if (parity == "")
{
parity = defaultPortParity.ToString();
}

return (Parity)Enum::Parse(Parity::typeid, parity);
}
``````
``````// Display PortParity values and prompt user to enter a value.
public static Parity SetPortParity(Parity defaultPortParity)
{
string parity;

Console.WriteLine("Available Parity options:");
foreach (string s in Enum.GetNames(typeof(Parity)))
{
Console.WriteLine("   {0}", s);
}

Console.Write("Enter Parity value (Default: {0}):", defaultPortParity.ToString(), true);

if (parity == "")
{
parity = defaultPortParity.ToString();
}

return (Parity)Enum.Parse(typeof(Parity), parity, true);
}
``````
``````' Display PortParity values and prompt user to enter a value.
Public Shared Function SetPortParity(defaultPortParity As Parity) As Parity
Dim parity As String

Console.WriteLine("Available Parity options:")
For Each s As String In [Enum].GetNames(GetType(Parity))
Console.WriteLine("   {0}", s)
Next

Console.Write("Enter Parity value (Default: {0}):", defaultPortParity.ToString(), True)

If parity = "" Then
parity = defaultPortParity.ToString()
End If

Return CType([Enum].Parse(GetType(Parity), parity, True), Parity)
End Function
``````