Function with parameters Learn programming with C# Sharp exercises

Lesson:

Functions


Exercise:

Function with parameters 136


Objetive:

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.


Code:

using System;
public class Exercise98
{
    public static void SayHello(string name)
    {
        Console.WriteLine("Hello" + name);
    }
    public static void SayGoodBye()
    {
        Console.WriteLine("Adios");
    }
    public static void Main(string[] args)
    {
        SayHello("Jonh");
        SayGoodBye();
    }
}