- #1
adjacent
Gold Member
- 1,552
- 63
I have made an app for calculating the area of a circle (##\pi r^2##) in VB. It works like a charm.
Then I have tried to make a similar one in C#.
This is my code:
When I click the area button, I want a text called name to be changed to "Area".-Works fine
I also made a variable "wat" to be changed to "Area"-Works fine
I now want to calculate the area using the radius in the Input text box. But Visual Studio says that Operator '*' cannot be applied to operands of type double and string.
What do I do? I used the same thing with VB. "Math.PI*(Input.Text)^2"
What is wrong here?
Then I have tried to make a similar one in C#.
This is my code:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Area_Circle_C_Sharp
{
public partial class Form1 : Form
{
String wat = "Area";
public Form1()
{
InitializeComponent();
}
private void Area_Click(object sender, EventArgs e)
{
wat = "Area";
Name.Text = "Area=";
Name_wat.Text =System.Math.PI * (Input.Text) ^ 2;
}
}
}
I also made a variable "wat" to be changed to "Area"-Works fine
I now want to calculate the area using the radius in the Input text box. But Visual Studio says that Operator '*' cannot be applied to operands of type double and string.
What do I do? I used the same thing with VB. "Math.PI*(Input.Text)^2"
What is wrong here?