Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to override property
Message
From
24/03/2007 18:43:34
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/03/2007 17:37:41
General information
Forum:
ASP.NET
Category:
Class design
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01208214
Message ID:
01208220
Views:
21
>I need to override property.
>The following code causes error. So I cannot declare virtual property for this.
>
>How to use virtual in this code ?
>
>
>class BusinessObject<EntityType> {
>	// Why next line causes error: The modifier 'virtual' is not valid for this item?
>	public virtual EntityType Entity;
>}
>
>class mybizobj : BusinessObject<MyEntity> {
>	public override MyEntity Entity {
>		get {
>			return null;
>		}
>	}
>}
>
>public class MyEntity { string myProperty;}
>
Andrus,
You cannot use virtual/override for fields. You can however use it for properties (reread your code you're not using it with a property but field).

public virtual EntityType Entity
{
get {}
set {}
}

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform