Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Override type of List in property
Message
De
28/11/2008 10:11:01
 
 
À
28/11/2008 09:52:46
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01364365
Message ID:
01364500
Vues:
10
>>If you take the code from yesterday and omit the 'new' keyword, then hit F6, I get this
>>
>>
>>Warning	3	'OrderB.OrderItems' hides inherited member 'Order.OrderItems'. Use the new keyword if hiding was intended.	D:\vs\Project\Test\Test\Test\Test.cs	66	26	Test
>>
>

>
>Which means that if you don't put the "new" keyword, it still works and "hides" the inherited member, so it's not really necessary ... except that you'll always get the warning. So, as a good programming practice, you *should* use the new keyword to avoid confusion. The warning is there in case you didn't mean to code it that way to hide the inherited member.
>
>~~Bonnie

Yes, I guess you're right, Bonnie

One thing I noticed though - without the new keyword - if you debug the B class, you see the 'old' property (as base.OrderItems with a count of zero) that is being hidden whilst with the new keyword, you do not
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform