|
-
March 30th, 2008, 10:07 AM
#1
Do have this sequence correct?
namespace.object.method.attribute
For insatance if i'm "using System;" namespace its then object.method, the question is to use attributes is it then object.method.attribute?
Ya, <-- n00b so thx for any help hehe
-
March 30th, 2008, 05:53 PM
#2
Re: Do have this sequence correct?
What do you mean by attritube? Do you mean an attribute to the class? Is so it is object.attribute. What material are you using to learn?
-
March 31st, 2008, 03:00 AM
#3
Re: Do have this sequence correct?
If you mean the attribute with which the method is annotated (e.g. [OperationContract]), then you have to use reflection to obtain it. Like this:
Code:
Type t = Type.GetType("namespace.object"); // assume by object you mean class
MethodInfo mi = t.GetMethod("YourMethodName");
object[] attrs = mi.GetCustomAttributes(false);
// and now, you can iterate over attrs and investigate them
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|