Baza znanjaIzpitno središče
SLSlovenščina
Izberi jezik13

CKTIS / C#

System.Reflection.PropertyInfo: praktična referenca

System.Reflection.PropertyInfo: praktična referenca: PropertyInfo opisuje lastnost in njena dostopnika get in set.

Različica: .NET API; verified against .NET 10 reference surface

Sintaksa

System.Reflection.PropertyInfo /* select a documented member or constructor */

PropertyInfo opisuje lastnost in njena dostopnika get in set.

Uporabite za preslikavo podatkov in orodja, ki upoštevajo razpoložljivost dostopnikov.

Indeksirana lastnost zahteva indeksne argumente, njen getter pa lahko izvede poljubno kodo.

Preverite manjkajoči get ali set; trimming lahko odstrani metapodatke.

Celoten program dejansko uporabi System.Reflection.PropertyInfo; natančno pričakovani stdout je 3.

Primeri

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

Celoten program dejansko uporabi `System.Reflection.PropertyInfo`; natančno pričakovani stdout je `3`.

Viri