Repository navigation
EN CSharp Attributes Reflection
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Attributes attach metadata to declarations; they do not necessarily execute an action themselves. Reflection inspects types and members at runtime. nameof produces a symbol name, typeof returns a Type object, and dynamic defers binding until runtime.
Save this example separately as Example.cs. Run it independently of the other examples on this page.
Example.cs:
// PROJECT-EXAMPLE
System.Type type = typeof(string);
System.Console.WriteLine(type.Name);
System.Console.WriteLine(type.IsValueType);Result:
String
False
sealed class Example
{
public string Name { get; set; } = "sample";
}
Type type = typeof(Example);
foreach (var property in type.GetProperties())
{
UO.Print(property.Name);
}dynamic value = new { Name = "Ore", Amount = 3 };
UO.Print($"{value.Name}: {value.Amount}");Reflection and dynamic do not provide access to game data that the client did not receive. When calling an unknown member via dynamic, an error occurs at runtime; regular typed code often detects it before execution.
Official documentation: Attributes, reflection and dynamic - Microsoft Learn.
ClassicUO — Bad Newbie & C# Scripts IDE