Say I have a generic class that at some point stores data, the data can and may be of any number of types. It may also perform methods or processing on such data. Because of that I'd only want it to store a changed value in case its handed the same value but I don't want to waste precious CPU cycles especially on older cpus or mobile devices as its unnecessary if the data hasn't changed any.
In C# your unable to compare generics, my guess is because, unlike C++, C# expands generics at runtime. However in C++ theres also a way you can use template specialization whereby you define the template class and then create a stub for particular types you know it may use.
My question is if I cant directly compare generic types, is there an alternate way, and if not is there such a thing as generic specialization in the C# world that I can try use to use as a means around the limitation, ideally though I'd prefer some method that allows me to find the type and thus be able to compare the values but I dont want anything hacky as this will be in production as a product.
The kinds of values it could contain could be anything from primitives to classes
by wiseguy12851 via /r/csharp