I am completely new at writing code, and I want to make a application that converts Fahrenheit to Celsius using Windows Forms and C#. I have been working on this for over a week and cannot even get to the debugging stage because I keep getting errors. I finally have it down to only two errors and cannot find any answers that help. I am really frustrated with this and was wondering what I was doing wrong and why I keep getting this error message. It tells me that the operator cannot be applied because of a .int. I have posted my code down below, to show what I have done already. Also, will someone please explain why this is happening, I read that I had to convert it to string. But the way I have tried to do that doesn't work. Please help.
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Fahrenheit_Click(object sender, EventArgs e)
{
double dblCelsius;
double dblFahrenheit;
dblCelsius = double.Parse(Fahrenheit.Text);
dblFahrenheit = (Celsius * 9 / 5) + 32;
Celsius.Text= Convert.ToString(dblCelsius);
}
private void Celsius_Click(object sender, EventArgs e)
{
double dblFahrenheit;
double dblCelsius;
dblFahrenheit = double.Parse(Celsius.Text);
dblCelsius = (Fahrenheit - 32) * 5 / 9;
Fahrenheit.Text = Convert.ToString(dblFahrenheit);
}
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
MOD EDIT: When posting code...USE CODE TAGS!!!
This post has been edited by JackOfAllTrades: 16 September 2010 - 03:04 PM

New Topic/Question
Reply




MultiQuote




|