Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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);
		}
	}
}
Comment

C# add two numbers using a method

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;
  }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to find how much digits in number c# 
Csharp :: c# socket receive 
Csharp :: c# system.drawing.color to system.windows.media.color 
Csharp :: Base64String to stream c# 
Csharp :: how to insert qoutation marks into string c# 
Csharp :: how to store more precise data then double c# 
Csharp :: C# infinite clock coroutine loop 
Csharp :: unity rotate vector 
Csharp :: check c# date for 0001/01/01 
Csharp :: how to run a function as administrator in c# 
Csharp :: snx turn off linux 
Csharp :: c# square every digit of a number 
Csharp :: restart animation unity 
Csharp :: override indexation C# 
Csharp :: c# unity camera follow 
Csharp :: c# add 1 
Csharp :: asp textarea 
Csharp :: equivalent to T extends TT in c# 
Csharp :: valid url in .net 
Csharp :: how to do fizzbuzz in c# 
Csharp :: how create another new app file in laravel 
Csharp :: unity spawn button 
Csharp :: c# stringbuilder to file 
Csharp :: c# @ before string 
Csharp :: Editor log location unity 
Csharp :: unity cast float to int 
Csharp :: how to change textMesh Pro unity 
Csharp :: c# average of 3 numbers 
Csharp :: deltatime 
Csharp :: how to start cmd in c# 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =