CKTIS / C#
System.Reflection.PropertyInfo: praktická reference
System.Reflection.PropertyInfo: praktická reference: PropertyInfo popisuje vlastnost a její přístupové metody get a set.
Verze: .NET API; verified against .NET 10 reference surface
Syntaxe
System.Reflection.PropertyInfo /* select a documented member or constructor */PropertyInfo popisuje vlastnost a její přístupové metody get a set.
Použijte pro mapování dat a nástroje respektující dostupnost přístupových metod.
Indexovaná vlastnost vyžaduje argumenty indexu a její getter může spustit libovolný kód.
Ověřte chybějící get nebo set; trimming může odstranit metadata.
Úplný program skutečně používá System.Reflection.PropertyInfo; přesně očekávaný stdout je 3.
Příklady
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var property = typeof(string).GetProperty(nameof(string.Length))!;
Console.WriteLine(property.GetValue("abc"));
Výsledek
3
Úplný program skutečně používá `System.Reflection.PropertyInfo`; přesně očekávaný stdout je `3`.