It seems strange that the type returned isn't the type from the registry. Why wouldn't .Net return an Int if the registry key holds an int, or a string if the value is string?? That's what a WinAPI call would do. Seems to be it's more obscure now.
I guess I could return the object returned from GetValue, but then your code has to cast whenever it's used. What do you think of the idea of writing a wrapper GetValue method, overloaded for each default value? So if I pass an int as the default, then the return value is cast to int, likewise for other values being returned based on the default value passed in.
>
>Now this is all fine when the registry value is a string, but it certainly isn't generic. What if the value is an int?>
>Have your method return an object rather than a string.
>
>~~Bonnie
>
>
>
>>I have this code:
>>
>>
>>public string GetRegistryValue(string sKeyName, string sKeyValue)
>>{
>> sKeyPath = "Software\\my_app\\" + sKeyName;
>>
>> string sRetVal = (string)Registry.LocalMachine.GetValue(sKeyPath, sKeyValue, "");
>>
>> return sValue;
>>}
>>
>>
>>Now this is all fine when the registry value is a string, but it certainly isn't generic. What if the value is an int?
>>
>>
>>Thanks
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people