"Mike P" <mi*******@gmail.com> wrote in message
news:u%***************@TK2MSFTNGP12.phx.gbl...
I just stumbled across some code with triplets, but I'm not sure what
they are used for. Why not just use ViewState instead? Can anybody
enlighten me?
It's just a silly serializable class with three public properties. Nothing
fancy at all.
However, When I need to have several values that belongs together in
ViewState (or in Session or in any List really); I typically define a
lightweight private class with public fields (I think properties are
overkill for such a class) as a placeholder for my values. Then I put and
read an instance of that class to the Dictionary.
The benefit is that there are now only one key in the Dictionary that
reduces the risk of collissions between aspx/ascx and also only one downcast
from Object to retrieve all values typesafe. I also find the code more
readable.
Hence, if I needed three values in ViewState that belongs together; I would
write my own class and not use that Triplet-thingy.
Happy Coding
- Michael S