Answers for "c #define function"

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
2

function c#

public int AddNumbers(int number1, int number2)
{
    int result = number1 + number2;
    return result;
}
Posted by: Guest on August-21-2020
0

function in c#

//function example
using System;
					
public class Program
{
	static void function(){
		Console.WriteLine("I am a function!");
	}
	public static void Main()
	{
		function();
	}
}
Posted by: Guest on March-30-2020
-1

functions c#

public void SayHello(string name) 
{
    Console.WriteLine("Hello");
}

public void SayName()
{
	Console.WriteLine("What is your name?");
	string name = Console.ReadLine(); 
	SayHello(name);
}
Posted by: Guest on September-03-2020

C# Answers by Framework

Browse Popular Code Answers by Language