What is this?

Discussion in 'ASP .Net' started by Jeff, Sep 12, 2006.

  1. Jeff

    Jeff Guest

    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
     
    Jeff, Sep 12, 2006
    #1
    1. Advertising

  2. 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



    "Jeff" <> wrote in message
    news:...
    > 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
    >
     
    Mark Fitzpatrick, Sep 12, 2006
    #2
    1. Advertising

  3. Jeff

    Guest

    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.


    Jeff wrote:
    > 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
     
    , Sep 12, 2006
    #3
  4. Jeff

    Jeff Guest

    Thanks



    "Mark Fitzpatrick" <> wrote in message
    news:%...
    > 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
    >
    >
    >
    > "Jeff" <> wrote in message
    > news:...
    >> 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
    >>

    >
    >
     
    Jeff, Sep 12, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page