Complete the code to get the type of the class using reflection.
Type type = typeof([1]);To get the type of a class, use typeof(ClassName).
Complete the code to get the custom attributes of the class.
object[] attrs = type.GetCustomAttributes([1], false);To get specific attributes, pass typeof(AttributeName) to GetCustomAttributes.
Fix the error in the code to check if the attribute exists on the class.
bool hasAttr = type.IsDefined([1], false);IsDefined expects a Type object for the attribute, so use typeof(MyAttribute).
Fill both blanks to get the first custom attribute and cast it to the correct type.
MyAttribute attr = (MyAttribute)type.GetCustomAttributes([1], false)[[2]];
GetCustomAttributes returns an array; index 0 is the first attribute. Use typeof to specify attribute type.
Fill all three blanks to read a property value from the attribute instance.
var value = attr.[1]; // Access property if (value [2] [3]) { Console.WriteLine("Property value is valid."); }
Access the property by name, compare it with the expected string using ==.
