TypeInfo.DeclaredProperties TypeInfo.DeclaredProperties TypeInfo.DeclaredProperties TypeInfo.DeclaredProperties Property

Definición

Obtiene una colección de las propiedades definidas por el tipo actual.Gets a collection of the properties defined by the current type.

public:
 virtual property System::Collections::Generic::IEnumerable<System::Reflection::PropertyInfo ^> ^ DeclaredProperties { System::Collections::Generic::IEnumerable<System::Reflection::PropertyInfo ^> ^ get(); };
public virtual System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo> DeclaredProperties { get; }
member this.DeclaredProperties : seq<System.Reflection.PropertyInfo>
Public Overridable ReadOnly Property DeclaredProperties As IEnumerable(Of PropertyInfo)

Valor de propiedad

Colección de las propiedades definidas por el tipo actual.A collection of the properties defined by the current type.

Ejemplos

En .NET para aplicaciones de la Tienda Windows 8.x.NET for Windows 8.x Store apps este ejemplo se usan los tipos de reflexión y los miembros del subconjunto para recuperar los métodos Calendar y las propiedades del tipo, incluidos los métodos y las propiedades heredados.This example uses the reflection types and members in the .NET para aplicaciones de la Tienda Windows 8.x.NET for Windows 8.x Store apps subset to retrieve the methods and properties of the Calendar type, including inherited methods and properties. Para ejecutar este código, péguelo en el archivo de código de una Tienda Windows 8.xWindows 8.x Store aplicación XAML que contenga un control Windows. UI. Xaml. Controls. textblock1TextBlock denominado.To run this code, paste it into the code file for a Tienda Windows 8.xWindows 8.x Store XAML app that contains a Windows.UI.Xaml.Controls.Textblock control named textblock1.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Navigation;
using System.Reflection;
using System.Globalization;
using System.Text;


namespace Reflection
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
           this.InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            TypeInfo t = typeof(Calendar).GetTypeInfo();
            IEnumerable<PropertyInfo> pList = t.DeclaredProperties;
            IEnumerable<MethodInfo> mList = t.DeclaredMethods;

            StringBuilder sb = new StringBuilder();
           
            sb.Append("Properties:");
            foreach (PropertyInfo p in pList)
            {

                sb.Append("\n" + p.DeclaringType.Name + ": " + p.Name);
            }
            sb.Append("\nMethods:");
            foreach (MethodInfo m in mList)
            {
                sb.Append("\n" + m.DeclaringType.Name + ": " + m.Name);
            }
            
            textblock1.Text = sb.ToString();

        }
    }
}
Imports Windows.UI.Xaml.Navigation
Imports System.Reflection
Imports System.Globalization
Imports System.Text

Public NotInheritable Class MainPage
    Inherits Page

    Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs)
        Dim t As TypeInfo = GetType(Calendar).GetTypeInfo()
        Dim pList As IEnumerable(Of PropertyInfo) = t.DeclaredProperties
        Dim mList As IEnumerable(Of MethodInfo) = t.DeclaredMethods

        Dim sb As New StringBuilder()

        sb.Append("Properties:")
        For Each p As PropertyInfo In pList

            sb.Append((vbLf + p.DeclaringType.Name & ": ") + p.Name)
        Next
        sb.Append(vbLf & "Methods:")
        For Each m As MethodInfo In mList
            sb.Append((vbLf + m.DeclaringType.Name & ": ") + m.Name)
        Next

        textblock1.Text = sb.ToString()

    End Sub
End Class

Se aplica a