C#.NET Program 2


Output : 




Code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Program_3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (radioButton1.Checked == true)
                {
                    double C = Convert.ToDouble(textBox1.Text);
                    textBox2.Text = Convert.ToString((C * 1.8) + 32);
                }
                if (radioButton2.Checked == true)
                {
                    double F = Convert.ToDouble(textBox2.Text);
                    textBox1.Text = Convert.ToString((F - 32) / 1.8);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Enter The Value Of Celsius Either Fahrenheit");
            }
        }
    }
}

No comments:

Post a Comment