Function values
I thought if i wrote a function to declare the sum procedure i wanted to know why i have to assign varibles to these new object i created, I wanted to know how do i input my own values and return the sum...I get the error saying cannot convert string to type int..Any Help out there?!?!?![]()
![]()
using
System;class
Add{
publicint x;publicint y;publicint sum;publicint getsum(){
int thesum;thesum = x + y;
return thesum;}
class MathA{
staticvoid Main(){
Add num1 =
new Add();Add num2 =
new Add();Add sum =
new Add();num1.x = 0;
num2.y = 0;
sum.sum = num1.x + num2.y;
Console.WriteLine("Enter two numbers");
Console.Write("Enter first number");
num1.x = Console.ReadLine();
Console.Write("Enter 2nd number");
num2.y = Console.ReadLine();
Console.WriteLine("The answer is {0}", sum.sum);
Console.WriteLine("Press enter to continue");
Console.ReadLine();
}
}
}

