.net - C#: Any difference whatsoever between "(subtype)data" and "data as subtype" typecasting? -


Assuming that I have an example of something that I know is a sub-class of a specific subtype A supertype in C #, I used to see typecasting like this kind of way (assuming "reference" is supertype):

  if (reference is subtype) { Subtype t = (sub-type) reference; }  

But recently I have come in the examples of examples which have been done with the same thing in this way:

  If (context Subtype) {subtype T = references in subtype; }  

Are these two completely equal? Is there a difference?

These are used in the same way, but are not the best choice. You should only be typing once:

  subtype t = reference as subtype; If (t! = Null) {...}  

The tap is more efficient than checking the type of check.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -