Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 Parity Enumeration
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Parity Enumeration

Specifies the parity bit for a SerialPort object.

Namespace:  System.IO.Ports
Assembly:  System (in System.dll)
Visual Basic (Declaration)
Public Enumeration Parity
Visual Basic (Usage)
Dim instance As Parity
C#
public enum Parity
Visual C++
public enum class Parity
JScript
public enum Parity
Member nameDescription
Supported by the .NET Compact FrameworkNoneNo parity check occurs.
Supported by the .NET Compact FrameworkOddSets the parity bit so that the count of bits set is an odd number.
Supported by the .NET Compact FrameworkEvenSets the parity bit so that the count of bits set is an even number.
Supported by the .NET Compact FrameworkMarkLeaves the parity bit set to 1.
Supported by the .NET Compact FrameworkSpaceLeaves the parity bit set to 0.

Use this enumeration when setting the Parity property for a serial port connection.

Parity is an error-checking procedure in which the number of 1s must always be the same—either even or odd—for each group of bits that is transmitted without error. In modem-to-modem communications, parity is often one of the parameters that must be agreed upon by sending parties and receiving parties before transmission can take place.

The following code example displays the possible values of the Parity enumeration to the console, then prompts the user to choose one. This code example is part of a larger code example provided for the SerialPort class.

Visual Basic
Public Shared Function SetPortParity(ByVal defaultPortParity As Parity) As Parity
    Dim newParity As String

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

    Console.Write("Parity({0}):", defaultPortParity.ToString())
    newparity = Console.ReadLine()

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

    Return CType([Enum].Parse(GetType(Parity), newParity), Parity)
End Function
C#
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("Parity({0}):", defaultPortParity.ToString());
    parity = Console.ReadLine();

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

    return (Parity)Enum.Parse(typeof(Parity), parity);
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

.NET Compact Framework

Supported in: 3.5, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker