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
Typeyou can useGetMethodto get an instance ofMethodInfo, which in turn has aGetMethodBodythat 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?