CKTIS / C#
System.Attribute: praktična referenca
System.Attribute: praktična referenca: Attribute je osnova metapodatkov, pripetih tipom in članom ter prebranih z refleksijo.
Različica: .NET API; verified on .NET 10.0.14
Sintaksa
System.Attribute /* select a documented member or constructor */Attribute je osnova metapodatkov, pripetih tipom in članom ter prebranih z refleksijo.
Uporabite za deklarativno konfiguracijo, ko porabnik izrecno interpretira ta atribut.
Dedovanje in AllowMultiple sta odvisna od AttributeUsage; branje lahko ustvari primerek atributa.
Trimming lahko odstrani metapodatke, ki jih analiza ne pozna; vrstni red več atributov ni del pogodbe.
Celoten program dejansko uporabi System.Attribute; natančno pričakovani stdout je True.
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;
Console.WriteLine(Attribute.IsDefined(typeof(Marked), typeof(ObsoleteAttribute)));
[Obsolete]
sealed class Marked { }
Rezultat
True
Celoten program dejansko uporabi `System.Attribute`; natančno pričakovani stdout je `True`.