Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to override property
Message
De
24/03/2007 18:43:34
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
24/03/2007 17:37:41
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01208214
Message ID:
01208220
Vues:
20
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform