Hi,
I've never developed in CSharp before and I'm trying to adapt an
existing user control written in CSharp. The user control inherits from
the DataGridColumn. I'd like for one of my controls properties to
override that of the DataGridColumn. Could somebody help with the
syntax? Currently my code for the property is as follows:
public virtual string HeaderStyle
{
get
{
object savedState = null;
savedState = this.ViewState["HeaderStyle"];
if (savedState != null)
{
return (string)savedState;
}
return "";
}
set
{
this.ViewState["HeaderStyle"] = value;
}
}
When I try to compile I get the message 'HeaderStyle hides inherited
member system.web.ui.webcontrols.datagridcolumn.headerstyle. To make
the current member override that implementation, add the override
keyword. Otherwise add the new keyword'. Please could someone confirm
that instead of
public virtual string HeaderStyle
I should have
public overrides string HeaderStyle
Thanks,
PaulI think it should be "override", without the "s".
An "override" is actually a "virtual" but it emphasize that it override
the virtual function declared in one of its base class. The thing is it
makes the purpose clearer, and avoid the case of accidental overriding
when you actually want a new virtual method, and acidentally create a
new virtual method while you actually want to overriding.
0 comments:
Post a Comment