Hmmm, good question.  I never ran in to needing to do this, though it would
be a plus.  As of now, I haven't seen anything in the framework that would
support this.

Look at the Attribute class that you inherit from
http://msdn.microsoft.com/en-us/library/system.attribute.aspx
Also look at the Attribute Members,
http://msdn.microsoft.com/en-us/library/system.attribute_members.aspx.

I read through the stuff and didn't see any built-in support from the
Framework.

Good luck in your search and if you do find a solution, please post it.

Best,

P.S. I will be doing some playing around to try to find a way to do this as
well.  If I find something, I will reply to this list.

Jim

On Tue, Aug 26, 2008 at 7:45 PM, Joe Enos <[EMAIL PROTECTED]> wrote:

>
> Quick question - I'm guessing the answer is no, but maybe someone has
> come across this scenario before:
>
> Is there a way to restrict the usage of an attribute so that it can
> only be applied to properties with a particular return type?  I
> haven't been able to find anyone with a similar question in the land
> of Google...
>
> For example - I want to restrict my attribute so it can only be used
> on string properties.
>
> [AttributeUsage(AttributeTargets.Property)]
> public class MyAttribute : Attribute { }
>
> // This would compile
> [MyAttribute]
> public string PropA { get; }
>
> // This would be a compilation error
> [MyAttribute]
> public int PropB { get; }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web 
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---

Reply via email to