CKTIS / C#
System.Reflection.PropertyInfo: praktična referenca
System.Reflection.PropertyInfo: praktična referenca: PropertyInfo opisuje svojstvo i njegove pristupnike get i set.
Verzija: .NET API; verified against .NET 10 reference surface
Sintaksa
System.Reflection.PropertyInfo /* select a documented member or constructor */PropertyInfo opisuje svojstvo i njegove pristupnike get i set.
Koristite za mapiranje podataka i alate koji poštuju dostupnost pristupnika.
Indeksirano svojstvo zahtijeva argumente indeksa, a njegov getter može izvršiti proizvoljan kod.
Provjerite nedostaje li get ili set; trimming može ukloniti metapodatke.
Cijeli program doista koristi System.Reflection.PropertyInfo; točno očekivani stdout jest 3.
Primjeri
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"));
Rezultat
3
Cijeli program doista koristi `System.Reflection.PropertyInfo`; točno očekivani stdout jest `3`.