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 :: variable gameobject unity 
Csharp :: how to rotate object in unity only on one axis 
Csharp :: parsing string to int c# 
Csharp :: how to set a transform equal to something unity 
Csharp :: joins List of strings 
Csharp :: c# list declaration 
Csharp :: unity find object by name recursion 
Csharp :: c# see if list contains any duplicates 
Csharp :: create list in c# 
Csharp :: datatable linq where clause c# 
Csharp :: switch expression c# 
Csharp :: c# remove word from string 
Csharp :: c# for statement 
Csharp :: unity cancel momentum 
Csharp :: difference between boxing and unboxing in c# 
Csharp :: c# get all namespaces in assembly 
Csharp :: C# datareadeer return null 
Csharp :: minimize maximize restore wpf buttons 
Csharp :: c# change language version to 9.0 
Csharp :: use slider in unity 
Csharp :: how to chceck for a tag in a trigger enter 2d unity 
Csharp :: random in f# 
Csharp :: Read a Word Document Using C# 
Csharp :: how to make a string in c# 
Csharp :: array reduce c# 
Csharp :: multidimensional arrays c# 
Csharp :: compact in laravrl 
Csharp :: how to use yield in c# 
Csharp :: c# loop through repeater items 
Csharp :: c# override gethashcode 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =