Is it possible to compute the hash of a class at runtime in C# (presumably through reflection)? To be clear, I don't want to compute the hashcode of an instance of said class, I want to compute the hash of the class code itself (if a function in the class changes, I'd expect a different hash code to be computed). Ideally this would only be sensitive to changes in the object code (and not just a hash of the string representation of the code itself).
Thanks in advance for your help,
-- Breck
If you have the Type
you can use GetMethod
to get an instance of MethodInfo
, which in turn has a GetMethodBody
that returns the IL for said method. You can then hash that.
I am curious. Why do you want to do this in the first place?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With