Here is the actual line of code I'm looking at:
ContentVersionCache cvc = ((PageBase)this.Page).cache;
I know this is a really basic question but I've 开发者_如何转开发just started learning C# so go easy on me :)
Cheers Iain
Break it up into smaller pieces:
(PageBase)this.Page
Casts this.Page
to a PageBase
. This means treating this.Page
as if it were a PageBase
, even though it may not be declared as such. If it isn't, then this will throw a runtime InvalidCastException
!
().cache
Access the cache
property or field of the PageBase
.
ContentVersionCache cvc = cache;
Store the cache to a local variable called cvc.
It casts the this.Page to a PageBase class .
this.Page is casted to PageBase class then assign its cache property to ContentVersionCache instance cvc
it convert this.Page to PageBase class and then call cache and assign it's value to cvc
精彩评论