//The "void" in this instance refers to the return type of this function
//This function won't have a return value.
void functionName(int parameter) {
//Code you want to run
}
//Calls the code in the function
functionName(Aninteger)
public int AddNumbers(int number1, int number2){ int result = number1 + number2; if(result > 10) { return result; } return 0;}
public void SayHello()
{
Console.WriteLine("Hello") ;
}
//as basic as it gets
//for a function
//function example
using System;
public class Program
{
static void function(){
Console.WriteLine("I am a function!");
}
public static void Main()
{
function();
}
}
public static string name_of_the_fucntion()
{
return "string";
}
public int AddNumbers(int number1, int number2)
{
int result = number1 + number2;
return result;
}
public void DoStuff()
{
Console.WriteLine("I'm doing something...");
}
// In C#, this is how we define a function:
/*
In this case, the function is called 'myFunction', it takes
1 parameter which is an integer and doesn't return anything (void).
*/
static void myFunction(int a)
{
// INSERT CODE HERE
Console.WriteLine(a);
}
public void SayHello(string name)
{
Console.WriteLine("Hello");
}
public void SayName()
{
Console.WriteLine("What is your name?");
string name = Console.ReadLine();
SayHello(name);
}