I have this code:
[MyAttribute(CustomAttribute="Value")]
class MyClass
{
// some code
}
Main()
{
MyClass a = new MyClass();
}
How to get value of CustomAttribute for instance a?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Along the lines of:
Can’t understand what you mean by “without using foreach”, except that GetCustomAttributes always returns an array of them (to account for having multiple attributes). If you know there can only be one, then just use the first one.