Some context, I'm still rather new at c# but I've updating c# code that someone else wrote that is incomplete. I've come across this code that seems to be giving me an error.
gblnEnableSSL = Convert.ToBoolean(Convert.ToInt32(Utils.GetSetting("Program", "Configuration", "SSL", "0")));
Utils.GetSetting("Program", "Configuration", "SSL", "0")
returns a string "false"
currently.
I've found that removing Convert.ToInt32()
solves my problem. But, I was unconvinced that someone simply added Convert.ToInt32()
that broke the code. I checked in the repo and was surprised to find that the previous code of the same line use to be:
gblnEnableSSL = Utils.GetSetting("Program", "Configuration", "SSL", "0").ToUpper() == "TRUE";
Which seemed to work as well. The checkbox checked value is set by using chkEnableSSL.Value = gblnEnableSSL;
My question is whether or not there is a difference between setting the value using a bool value or a string value. Also, is a difference between chkEnableSSL.value
vs chkEnableSSL.Checked
?
Edit: I'm not getting a compiler or run-time error with the previous code. It does not perform the code afterwards. For example, i have txtDataSource.Text = strDataSource;
immediately after and it does not set the text unless i comment out gblnEnableSSL = ...
or remove the Convert.ToInt32()
.
Aucun commentaire:
Enregistrer un commentaire