Programming Course in C# ¡Free!

Function with parameters

 Saturday, April 06, 2013 published by Exercises C#
Proposed exercise

Create a program whose Main must be like this:

public static void Main()
{
    SayHello("John");
    SayGoodbye();
}

SayHello and SayGoodbye are functions that you must define and that will be called from inside Main. As you can see in the example. SayHello must accept an string as a parameter.

Output



Solution


using System;
public class FParameters
{   
public static void SayHello(string name)
{
Console.WriteLine("Hello" + name);
}

public static void SayGoodBye()
{
Console.WriteLine("Bye");
}

public static void Main()
{
SayHello("Jonh");
SayGoodBye();
}
}