|
Este artículo proviene de un motor de traducción automática. Mueva el puntero sobre las frases del artículo para ver el texto original. Más información.
|
Traducción
Original
|
FieldAttributes (Enumeración)
Esta enumeración tiene un atributo FlagsAttribute que permite una combinación bit a bit de los valores de miembro.
Espacio de nombres: System.Reflection
Ensamblado: mscorlib (en mscorlib.dll)
| Nombre de miembro | Descripción | |
|---|---|---|
![]() ![]() ![]() | FieldAccessMask | |
![]() ![]() ![]() | PrivateScope | |
![]() ![]() ![]() | Private | |
![]() ![]() ![]() | FamANDAssem | |
![]() ![]() ![]() | Assembly | |
![]() ![]() ![]() | Family | |
![]() ![]() ![]() | FamORAssem | |
![]() ![]() ![]() | Public | |
![]() ![]() ![]() | Static | |
![]() ![]() ![]() | InitOnly | |
![]() ![]() ![]() | Literal | |
![]() ![]() ![]() | NotSerialized | |
![]() ![]() ![]() | SpecialName | |
![]() ![]() ![]() | PinvokeImpl | |
![]() | ReservedMask | |
![]() ![]() ![]() | RTSpecialName | |
![]() ![]() ![]() | HasFieldMarshal | |
![]() ![]() ![]() | HasDefault | |
![]() ![]() ![]() | HasFieldRVA |
using System; using System.Reflection; public class Demo { // Make three fields: // The first field is private. private string m_field = "String A"; // The second field is public. public string Field = "String B"; // The third field is public const (hence also literal and static), // with a default value. public const string FieldC = "String C"; } public class Myfieldattributes { public static void Main() { Console.WriteLine ("\nReflection.FieldAttributes"); Demo d = new Demo(); // Get a Type object for Demo, and a FieldInfo for each of // the three fields. Use the FieldInfo to display field // name, value for the Demo object in d, and attributes. // Type myType = typeof(Demo); FieldInfo fiPrivate = myType.GetField("m_field", BindingFlags.NonPublic | BindingFlags.Instance); DisplayField(d, fiPrivate); FieldInfo fiPublic = myType.GetField("Field", BindingFlags.Public | BindingFlags.Instance); DisplayField(d, fiPublic); FieldInfo fiConstant = myType.GetField("FieldC", BindingFlags.Public | BindingFlags.Static); DisplayField(d, fiConstant); } static void DisplayField(Object obj, FieldInfo f) { // Display the field name, value, and attributes. // Console.WriteLine("{0} = \"{1}\"; attributes: {2}", f.Name, f.GetValue(obj), f.Attributes); } } /* This code example produces the following output: Reflection.FieldAttributes m_field = "String A"; attributes: Private Field = "String B"; attributes: Public FieldC = "String C"; attributes: Public, Static, Literal, HasDefault */
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (no se admite el rol Server Core), Windows Server 2008 R2 (se admite el rol Server Core con SP1 o versiones posteriores; no se admite Itanium)
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.


