No, you have to assign it to the whole property. I tried to do this:
public static string Home
{
[method: Obsolete]
get
{
return null;
}
[method: Obsolete]
set
{
}
}
And it gave me this:
Error 1 Attribute 'Obsolete' is not valid on property or event accessors. It
is valid on 'class, struct, enum, constructor, method, property, indexer,
field, event, interface, delegate' declarations only.
c:\temp\WindowsApplication1\WindowsApplication1\Pr ogram.cs 23 14
WindowsApplication1
Note, you can attach other attributes to the accessors inside a
property, just not the Obsolete one. For example, the Description attribute
can be applied like so:
public static string Home
{
[method: Description("hello")]
get
{
return null;
}
[method: Obsolete]
set
{
}
}
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"dlgproc" <dl*****@discussions.microsoft.comwrote in message
news:74**********************************@microsof t.com...
Does anyone know if it's possible to apply an ObsoleteAttribute to just
the
Get or Set of part a property in .NET 1.1?
From my tests, I don't think you can, but I wanted to make sure.
Thanks,
DlgProc