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
 
hI Jane:

I think now you'll have to define what you mean by 'cache'.
 
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
 

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

Back
Top