Help!! Cache a method..

  • Thread starter Thread starter Jane204
  • Start date Start date
J

Jane204

Hi,

How to cache a generic method (not a webmethod) within a class?

Thanks a lot!

Jane
 
Jane204 said:
How to cache a generic method (not a webmethod) within a class?

What exactly do you mean? Can you give an example of what you want?
 
Jon Skeet said:
What exactly do you mean? Can you give an example of what you want?

Hi,

class Test{

// I want to cache just the following method
void foo(){
// do something
}
}

Thanks.

Jane
 
Yes... We do know what a method looks like...
I guess you want to save the results of an expensive operation, so you don't
have to recalculate its value if it gets called again with the same
parameters?
If so, use a HashTable to store the calculation results, and check if you
have an old result in the table before calculating a new one.

Niki

Jane204 said:
Jon Skeet [C# MVP] <[email protected]> wrote in message
What exactly do you mean? Can you give an example of what you want?

Hi,

class Test{

// I want to cache just the following method
void foo(){
// do something
}
}

Thanks.

Jane
 
Back
Top