tags:

views:

97

answers:

4

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

+2  A: 

It casts the this.Page to a PageBase class .

Cheeso
+13  A: 

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.

Matthew Scharley
A very detailed and helpful response. Well done sir! Have a green tick :)
Iain Fraser
+1 for the very pedagogical exposition.
Mathias
That's funny because I always figured I'd never have the patience to be a teacher.
Matthew Scharley
+1  A: 

this.Page is casted to PageBase class then assign its cache property to ContentVersionCache instance cvc

Himadri
A: 

it convert this.Page to PageBase class and then call cache and assign it's value to cvc

Davit Siradeghyan