Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Validating on Overridable method
Message
De
05/09/2011 14:29:05
 
 
À
05/09/2011 13:24:49
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01522449
Message ID:
01522751
Vues:
19
>>Maybe
loType.BaseType.Name
Untested. And it only gives the immediate parent - if the actual class has a deeper hierarchy it won't work.....
>
>Yes, as you can see in the other message, this is what I used. And, in the way I am using it on, this is only class from base classes from the framework.

As long as you are sure it's safe.
If someone can sub-class your base class there's nothing to stop them deriving from the derived class - in which case your code would break. If your class is directly derived from Object then you could identify it like this:
Dim parent As Type = t ' where t is type of actual class
While True
	If parent.BaseType = GetType([Object]) Then
		Exit While
	Else
		parent = parent.BaseType
	End If
End While

'Parent is now your base class
But at that point it probably makes as much sense to pass in the name of the class anyway....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform