CKTIS / C#
System.Reflection.PropertyInfo: praktická referencia
System.Reflection.PropertyInfo: praktická referencia: PropertyInfo opisuje vlastnosť a jej prístupové metódy get a set.
Verzia: .NET API; verified against .NET 10 reference surface
Syntax
System.Reflection.PropertyInfo /* select a documented member or constructor */PropertyInfo opisuje vlastnosť a jej prístupové metódy get a set.
Použite na mapovanie údajov a nástroje rešpektujúce dostupnosť prístupových metód.
Indexovaná vlastnosť vyžaduje argumenty indexu a jej getter môže spustiť ľubovoľný kód.
Overte chýbajúci get alebo set; trimming môže odstrániť metadáta.
Úplný program skutočne používa System.Reflection.PropertyInfo; presne očakávaný stdout je 3.
Prí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ýsledok
3
Úplný program skutočne používa `System.Reflection.PropertyInfo`; presne očakávaný stdout je `3`.