Question au sujet d'une méthode abstraite
Bonjour!
Voici ma classe parent : BusinessBase
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
[Serializable]
public abstract class BusinessBase : ICloneable
{
#region Private Properties
private Hashtable brokenRules;
#endregion
#region Constructors
public BusinessBase()
{
brokenRules = new Hashtable();
}
#endregion
....
#region Methods
protected abstract void Initialize();
protected abstract void Initialize(BusinessBase businessBase);
protected abstract void Initialize(DataRow row);
public abstract override string ToString();
public abstract object Clone();
#endregion
#region SQL Methods
protected abstract void Load(int id);
protected abstract void Save();
protected abstract void Delete();
#endregion
} |
et un exemple de classe qui hérite de BusinessBase
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
public class FeatureType : BusinessBase
{
#region Private Properties
private int _featureTypeId;
private string _featureTypeName;
private int _featureTypePosition;
private bool _featureTypeHasFeatures;
#endregion
#region Constructors
public FeatureType() :
base()
{
Initialize();
}
public FeatureType(FeatureType featureType) :
base()
{
Initialize(featureType);
}
public FeatureType(DataRow row) :
base()
{
Initialize(row);
}
public FeatureType(int featureTypeId) :
base()
{
Load(featureTypeId);
}
#endregion
...
#region Methods
protected override void Initialize()
{
...
}
protected override void Initialize(FeatureType featureType)
{
this._featureTypeId = 0;
this.FeatureTypeName = featureType.FeatureTypeName;
this.FeatureTypePosition = featureType.FeatureTypePosition;
this.FeatureTypeHasFeatures = featureType.FeatureTypeHasFeatures;
}
protected override void Initialize(DataRow row)
{
...
}
public override string ToString()
{
return String.Format("FeatureType : [{0}, {1}, {2}, {3}]",
this.FeatureTypeId,
this.FeatureTypeName,
this.FeatureTypePosition,
this.FeatureTypeHasFeatures);
}
public override object Clone()
{
return new FeatureType(this);
}
#endregion
#region SQL Methods
protected override void Load(int airpotId)
{
...
}
protected override void Save()
{
...
}
protected override void Delete()
{
...
}
#endregion
} |
Et ma question... Comment se fait-il que je reçoive l'erreur suivante ?
Citation:
'Feature' does not implement inherited abstract member 'BusinessBase.Initialize(BusinessBase)'
Le paramètre de la méthode Initialize(FeatureType featureType) recoit bel et bien un parametre de type "enfant de" BusinessBase... Qu'est-ce qui se passe?
Merci de vos éclaircissements!!