Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Constructor firing Inheritance in C#
Message
De
20/01/2006 12:58:19
 
 
À
19/01/2006 20:17:04
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01088705
Message ID:
01088956
Vues:
9
Off the top of my head, from what I know you can do it from the constructor of the derived class:
public DerivedClass (string myParam) : base("TableName")
{
 yada, yada, yada.
}
The parameter list gets run first, so that involves the call to the base class constructor.

Just to practice my knowledge, you can also use "this" in the param list to specify another constructor in the same class. So if you have:

1) A constructor that accepts 2 params, a first and last name
2) A constructor that accepts 3 params, first name, last name and ssn

You can have the 2nd constructor header

public myConstructor(string mySsn) : this(string first, string last)

So you only write the constructor code to process name once.


>>>You can add a call to base after setting the tablename field value<
>
>No, John ... you can't do that in the constructor of a class.
>
>I'm sure there's a way to do what Rick wants to do, but I'm not coming up with it off the top of my head. Maybe I need to sleep on it. <s>
>
>~~Bonnie
>
>
>
>
>>>
>>>
>>>public class AuthorBizObj: BizObj
>>>{
>>>   public AuthorBizObj()
>>>   {
>>>      this.TableName="Authors";
>>>   }
>>>}
>>>
>>>
>>
>>You can add a call to base after setting the tablename field value

(On an infant's shirt): Already smarter than Bush
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform