Hi
im new in C# so i want to write a program which will take two numbers from the user and add them.
I create a class and method and call it. but i wont run can you help me to find my fault here is my code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SumNumbers_Method_Call
{
class sum
{
int result = 0;
public static int Sum(int firstNumber, int secondNumber) {
int result = firstNumber + secondNumber;
return result;
}
}
}
----------------------------------------------
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 SumNumbers_Method_Call
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int result = 0;
int32.TryParse
int calculate = sum.Sum(textBox1.Text,textBox2.Text);
MessageBox.Show("result is " + result);
}
}
}
im new in C# so i want to write a program which will take two numbers from the user and add them.
I create a class and method and call it. but i wont run can you help me to find my fault here is my code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SumNumbers_Method_Call
{
class sum
{
int result = 0;
public static int Sum(int firstNumber, int secondNumber) {
int result = firstNumber + secondNumber;
return result;
}
}
}
----------------------------------------------
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 SumNumbers_Method_Call
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int result = 0;
int32.TryParse
int calculate = sum.Sum(textBox1.Text,textBox2.Text);
MessageBox.Show("result is " + result);
}
}
}