Answers for "append two integer in c#"

C#
1

add two numbers in c#

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);
		}
	}
}
Posted by: Guest on August-28-2021
1

c# add two int variables

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));
Posted by: Guest on November-14-2021

C# Answers by Framework

Browse Popular Code Answers by Language