using System;
namespace Add{
public class Program{
public static int addition(int a, int b){
return (a+b);
}
public static void Main(){
int a,b;
int sum;
Console.Write("Enter first number: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter second number: ");
b = Convert.ToInt32(Console.ReadLine());
sum = addition(a,b);
Console.WriteLine("Sum is: " + sum);
}
}
}
int a = 1039;
int b = 7056;
int newNumber = int.Parse(a.ToString() + b.ToString());
//Or
int newNumber = Convert.ToInt32(string.Format("{0}{1}", a, b));
using System;
public class Program
{
public static void Main(String[] args)
{
int a = 1;
int b = 2;
int answer = sum(a,b);//calling the method
Console.WriteLine(answer);
}
//sum is a method
static int sum(int a,int b)
{
return a+b;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Addition
{
public class Program
{
public static void Main(string[] args)
{
int a;
int b;
int add;
Console.WriteLine("Enter Your First Number: "); //allow user input
a = int.Parse(Console.ReadLine()); //convert to answer (string) to int
Console.WriteLine("Enter Your Second Number: ");
b = int.Parse(Console.ReadLine());
add = a + b; //add the input numbers
Console.WriteLine(); //blank space
Console.WriteLine(a + "+" + b + "=" + add); // Print the sum of a + b
Console.WriteLine(); //blank space
}
}
}
//c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Program
{
public class Addition
{
public static void Main(string[] args)
{
int x = 5; //set value for x
int y = 6; //set value for y
int sum;
sum = x + y; //add the numbers
Console.WriteLine(sum); // Print the sum of x + y
}
}
}