An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
Additional information: Value cannot be null.
for this:
var flags = uint.Parse((string)checkedRadioButton.Tag, System.Globalization.NumberStyles.HexNumber);
An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
Additional information: Value cannot be null.
for this:
var flags = uint.Parse((string)checkedRadioButton.Tag, System.Globalization.NumberStyles.HexNumber);
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Yogi SRank #511 · 4.8K reputationPosted Feb 8, 2024, 12:15 AM EST
The flags variable did not find checkedRadioButton so you get this error. Put breakpoint and see the full message and post it here so that we can understand more on it.
NaveenRank #6,081 · 277 reputationPosted Feb 8, 2024, 12:24 AM EST
Hi Yogi,
RadioButton checkedRadioButton = groupBoxRegistrationFlag.Controls.OfType().FirstOrDefault(r => r.Checked);
var flags = uint.Parse((string)checkedRadioButton.Tag, System.Globalization.NumberStyles.HexNumber);
check this.
Thanks!
Amit MohantyRank #112 · 20K reputationPosted Feb 8, 2024, 12:52 AM EST
The issue is occurring because checkedRadioButton is null, meaning no radio button is currently checked in the groupBoxRegistrationFlag.Controls collection.
You should check if checkedRadioButton is not null before attempting to access its properties.
RadioButton checkedRadioButton = groupBoxRegistrationFlag.Controls.OfType().FirstOrDefault(r => r.Checked); if (checkedRadioButton != null) { var flags = uint.Parse((string)checkedRadioButton.Tag, System.Globalization.NumberStyles.HexNumber); } else { // You can throw an exception, provide a default value, or take any other appropriate action }