What is this?

J

Jeff

Hey

I've bought the book "ASP.NET 2.0 website programming, Problem, Design,
Solution" and some of its code examples is this code:

protected Cache Cache
{
get ( return HttpContext.Current.Cache; )
}

I've got problems understanding this: "Cache Cache", I guess the first
"cache" here is the datatype? What is the second "cache"? is it the method
name? (I doubt it is the methos name, both datatype and method name is the
same)... And if this was a method then from my understanding there should be
some parenthesis after the method name??

Jeff
 
M

Mark Fitzpatrick

Jeff,
It's not a method name, it's a property. The way you can tell a
property is that it will have a get and/or set accessor. Basically it's a
shortcut to a value that could be a variable, a constant, or a simple
reference. In this case, it's a shortcut to the Cache to make life simpler
instead of typing out HttpContext.Current.Cache all the time in code.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
M

michaelkb

It's a property, but I don't think the same case and name exactly as
it's type is a good idea.. even if it will compile. Looks liek
something you'de use maybe in a rendered control so you don't have to
reference the full name every time I guess.
 
J

Jeff

Thanks



Mark Fitzpatrick said:
Jeff,
It's not a method name, it's a property. The way you can tell a
property is that it will have a get and/or set accessor. Basically it's a
shortcut to a value that could be a variable, a constant, or a simple
reference. In this case, it's a shortcut to the Cache to make life simpler
instead of typing out HttpContext.Current.Cache all the time in code.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top