Übersetzung vorschlagen
 
Andere Vorschläge:

progress indicator
Keine anderen Vorschläge
Per Mausklick bewerten und Feedback geben
MSDN
MSDN Library
Visual Studio 2010
Visual Studio
Visual C#
C#-Referenz
C#-Schlüsselwörter
 Wert
Alle reduzieren/Alle erweitern Alle reduzieren
Inhalt anzeigen:  Englisch mit deutscher ÜbersetzungInhalt anzeigen: Englisch mit deutscher Übersetzung
Visual Studio 2010 - Visual C#
value (C# Reference)

The contextual keyword value is used in the set accessor in ordinary property declarations. It is similar to an input parameter on a method. The word value references the value that client code is attempting to assign to the property. In the following example, MyDerivedClass has a property called Name that uses the value parameter to assign a new string to the backing field name. From the point of view of client code, the operation is written as a simple assignment.

C#
class MyBaseClass
{
    // virtual auto-implemented property. Overrides can only
    // provide specialized behavior if they implement get and set accessors.
    public virtual string Name { get; set; }

    // ordinary virtual property with backing field
    private int num;
    public virtual int Number
    {
        get { return num; }
        set { num = value; }
    }
}


class MyDerivedClass : MyBaseClass
{
    private string name;

   // Override auto-implemented property with ordinary property
   // to provide specialized accessor behavior.
    public override string Name
    {
        get
        {
            return name;
        }
        set
        {
            if (value != String.Empty)
            {
                name = value;
            }
            else
            {
                name = "Unknown";
            }
        }
    }

}

For more information about the use of value, see Properties (C# Programming Guide).

For more information, see the C# Language Specification. The language specification is the definitive source for C# syntax and usage.

Reference

Concepts

Other Resources

Visual Studio 2010 - Visual C#
value (C#-Referenz)

Das kontextbezogene Schlüsselwort value wird im set-Accessor in herkömmlichen Eigenschaftendeklarationen verwendet. Es ähnelt einem Eingabeparameter in einer Methode. Das Wort value verweist auf den Wert, der der Eigenschaft vom Clientcode zugewiesen werden soll. MyDerivedClass verfügt im folgenden Beispiel über die Eigenschaft Name, die dem Sicherungsspeicher name mit dem value-Parameter eine neue Zeichenfolge zuweist. Aus der Clientcodeperspektive wird der Vorgang als einfache Zuweisung geschrieben.

C#
class MyBaseClass
{
    // virtual auto-implemented property. Overrides can only
    // provide specialized behavior if they implement get and set accessors.
    public virtual string Name { get; set; }

    // ordinary virtual property with backing field
    private int num;
    public virtual int Number
    {
        get { return num; }
        set { num = value; }
    }
}


class MyDerivedClass : MyBaseClass
{
    private string name;

   // Override auto-implemented property with ordinary property
   // to provide specialized accessor behavior.
    public override string Name
    {
        get
        {
            return name;
        }
        set
        {
            if (value != String.Empty)
            {
                name = value;
            }
            else
            {
                name = "Unknown";
            }
        }
    }

}

Nähere Informationen zur Verwendung von value finden Sie unter Eigenschaften (C#-Programmierhandbuch).

Weitere Informationen finden Sie in der C#-Sprachspezifikation. Die Sprachspezifikation ist die verbindliche Quelle für die Syntax und Verwendung von C#.

Referenz

Konzepte

Weitere Ressourcen

Communityinhalt   Was ist Community Content?
Neuen Inhalt hinzufügen RSS  Anmerkungen
Processing
© 2012 Microsoft. Alle Rechte vorbehalten. Nutzungsbedingungen | Markenzeichen | Informationen zur Datensicherheit
Page view tracker