I was just wondering if there is a "best" choice from the following
couple of ways of returning a value from a method:
1)
private HashAlgorithm GetSpecificHash Algorithm(strin g hashString){
if (hashString == "MD5") {
return System.Security .Cryptography.M D5.Create();
} else {
return System.Security .Cryptography.S HA512.Create();
}
}
or
2)
private HashAlgorithm GetSpecificHash Algorithm(strin g hashString){
HashAlgorithm hash;
if (hashString == "MD5") {
hash = System.Security .Cryptography.M D5.Create();
} else {
hash = System.Security .Cryptography.S HA512.Create();
}
return hash;
}
Is there a general opinion on which is better style?
Thanks,
Matt
couple of ways of returning a value from a method:
1)
private HashAlgorithm GetSpecificHash Algorithm(strin g hashString){
if (hashString == "MD5") {
return System.Security .Cryptography.M D5.Create();
} else {
return System.Security .Cryptography.S HA512.Create();
}
}
or
2)
private HashAlgorithm GetSpecificHash Algorithm(strin g hashString){
HashAlgorithm hash;
if (hashString == "MD5") {
hash = System.Security .Cryptography.M D5.Create();
} else {
hash = System.Security .Cryptography.S HA512.Create();
}
return hash;
}
Is there a general opinion on which is better style?
Thanks,
Matt
Comment