471,348 Members | 1,304 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Please help override property


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
object savedState = null;
savedState = this.ViewState["HeaderStyle"];
if (savedState != null)
return (string)savedState;
return "";
this.ViewState["HeaderStyle"] = value;

When I try to compile I get the message 'HeaderStyle hides inherited
member system.web.ui.webcontrols.datagridcolumn.headersty le. 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



Dec 9 '05 #1
1 5753
I 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.

Dec 9 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Eric Johannsen | last post: by
7 posts views Thread by Dave Y | last post: by
8 posts views Thread by bdeviled | last post: by
1 post views Thread by paulsmith5 | last post: by
4 posts views Thread by R. MacDonald | last post: by
1 post views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.