How do you override attributes of a .NET framework class in child class?
The base class WebPart
has a property defined like this:
[WebBrowsable(true)]
public virtual string CatalogIconImageUrl { get; set; }
Can I have a child class which will just override the attribute as shown below? I have tried but it doesn't work.
[WebBrowsable(false)]
public override string CatalogIconImageUrl
{
get
{
return base.CatalogIconImageUrl;
}
set
{开发者_高级运维
base.CatalogIconImageUrl = value;
}
}
The base class is a .NET framework class, documented here:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webpart.catalogiconimageurl.aspx
i am not a 100% sure but should the code be more like
internal string _catalogIconImageUrl;
[WebBrowsable(false)]
public override string CatalogIconImageUrl
{
get
{
return _catalogIconImageUrl;
}
set
{
_catalogIconImageUrl = value;
}
}
this is so the variable is attached to the child object and the variable will still be available when the CatalogIconImageUrl property is called by the parent class/type.
精彩评论