// Method with parameters public void MyMethod(int firstParam, [Obsolete("This parameter is deprecated")] string secondParam) { // Check if "Obsolete" attribute is defined for second parameter bool isObsolete = typeof(ParameterInfo).GetMethod("IsDefined").IsDefined( typeof(ObsoleteAttribute), false); }
// Constructor with parameter public MyClass([Required] string myParam) { // Check if "Required" attribute is defined for parameter bool isRequired = typeof(ParameterInfo).GetMethod("IsDefined").IsDefined( typeof(RequiredAttribute), false); }These examples use the System.Reflection namespace in C# and are likely found in the reflection library.