CKTIS / C#
System.Attribute: praktická referencia
System.Attribute: praktická referencia: Attribute je základom metadát pripojených k typom a členom a čítaných pomocou reflexie.
Verzia: .NET API; verified on .NET 10.0.14
Syntax
System.Attribute /* select a documented member or constructor */Attribute je základom metadát pripojených k typom a členom a čítaných pomocou reflexie.
Použite na deklaratívnu konfiguráciu, keď konzument daný atribút výslovne interpretuje.
Dedičnosť a AllowMultiple závisia od AttributeUsage; čítanie môže vytvoriť inštanciu atribútu.
Trimming môže odstrániť metadáta neznáme analýze; poradie viacerých atribútov nie je súčasťou kontraktu.
Úplný program skutočne používa System.Attribute; presne očakávaný stdout je True.
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;
Console.WriteLine(Attribute.IsDefined(typeof(Marked), typeof(ObsoleteAttribute)));
[Obsolete]
sealed class Marked { }
Výsledok
True
Úplný program skutočne používa `System.Attribute`; presne očakávaný stdout je `True`.