I was trying to play with custom attributes of c#.
And as a part of this, consider this scenario: I have my client class which gives me a string to hash and specifies the hashing algorithm using custom attributes.
I was able to come up to this but stuck up when how to retrieve the custom attribute value.
class HashAlgorithmAttribute : Attribute { private string hashAlgorithm; public HashAlgorithmAttribute(string hashChoice) { this.hashAlgorithm= hashChoice; } } [HashAlgorithm("XTEA")] class ClientClass { public static string GetstringToBeHashed() { return "testString"; } } class ServerClass { public void GetHashingAlgorithm() { var stringToBeHashed = ClientClass.GetstringToBeHashed(); ///object[] hashingMethod = typeof(HashAlgorithm).GetCustomAttributes(typeof(HashAlgorithm), false); } }