---
title: "How to use Radio button ( For male and female ) in the form application in C#?"  
description: "How to use Radio button ( For male and female ) in the form application in C#?"  
author: "Abhishek Srivasatava"  
published: 2016-10-25  
updated: 2020-09-24  
canonical: https://www.mindstick.com/interview/23090/how-to-use-radio-button-for-male-and-female-in-the-form-application-in-c-sharp  
category: "c#"  
tags: ["c#", "sql server"]  
reading_time: 1 minute  

---

# How to use Radio button ( For male and female ) in the form application in C#?

Here is the code to use radio button in C# using SQL.

\

```
           if (radioButton1.Checked == true || radioButton2.Checked == true)            {                if
                    (radioButton1.Checked == true)                {                    savecom.Parameters.AddWithValue("@Sex", "Male");                }                else                {                   
                   savecom.Parameters.AddWithValue("@Sex", "Female");                }            }            else            {                savecom.Parameters.AddWithValue("@Sex", null);            }
```

**\**

Always use the else case otherwise error shall be come during testing.

## Answers

### Answer by Abhishek Srivasatava

Here is the code to use radio button in C# using SQL.

\

```
           if (radioButton1.Checked == true || radioButton2.Checked == true)            {                if
                    (radioButton1.Checked == true)                {                    savecom.Parameters.AddWithValue("@Sex", "Male");                }                else                {                   
                   savecom.Parameters.AddWithValue("@Sex", "Female");                }            }            else            {                savecom.Parameters.AddWithValue("@Sex", null);            }
```

**\**

Always use the else case otherwise error shall be come during testing.


---

Original Source: https://www.mindstick.com/interview/23090/how-to-use-radio-button-for-male-and-female-in-the-form-application-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
