Answers for "function declaration c#"

C#
1

functions in c#

using System;
					
public class Program
{
	public static void Main()
	{
		//functions can have retun type name and optional parameters 
		Console.WriteLine("-------functions---------");
		float MilesToKm(float miles){
			float km = miles*1.6f ; 
			return km ;
		}
		//calling a function
		Console.WriteLine(MilesToKm(3.0f));
		
		
		
	}
}
Posted by: Guest on November-02-2021
0

how to define a function in c#

//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)
Posted by: Guest on April-19-2021

Code answers related to "function declaration c#"

C# Answers by Framework

Browse Popular Code Answers by Language