public static class Program
public static void Main()
var a = GetCustomAttribute<Sighs, MyAttributeForDemo>();
Console.WriteLine(a.SomeNumber);
public static TAttribute GetCustomAttribute<TTarget, TAttribute>()
where TAttribute : Attribute
return typeof(TTarget).GetTypeInfo().GetCustomAttributes().OfType<TAttribute>().SingleOrDefault();
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public class MyAttributeForDemo : Attribute
public MyAttributeForDemo(int i)
public int SomeNumber { get; set; }