Start learning free

LESSON 39 OF 674 · FUNCTIONS I

Exercise: Create Function with Parameters in C#

Practice

We've written this code:

public void MainFunction() {
	Console.WriteLine("My name is Andy");
	Console.WriteLine("I code in Python");
	Console.WriteLine("I have a dog");

	Console.WriteLine("My name is Mike");
	Console.WriteLine("I code in Java");
	Console.WriteLine("I have a cat");

	Console.WriteLine("My name is Sarah");
	Console.WriteLine("I code in JavaScript");
	Console.WriteLine("I have a parrot");
}

Write the same code in a better way by creating and calling a function with parameters PrintMessages()

STEP 1 OF 5
    Ctrl + Enter to check