Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Methods Creation Practice | Methods
course content

Зміст курсу

C# Basics

Methods Creation PracticeMethods Creation Practice

Following is a code for outputting a triangle shape using multiple Console.WriteLine statements:

cs

main.cs

Create a new method called displayTriangle with the above code and call it in the main function.

cs

main.cs

1. Create a method using static void methodName() syntax and put the triangle code inside it.
Afterwards, execute it in the main method.

using System;

namespace ConsoleApp
{
    internal class Program
    {
        // Create a method here
        static void displayTriangle()
        {
            Console.WriteLine("*********");
            Console.WriteLine("*******");
            Console.WriteLine("*****");
            Console.WriteLine("***");
            Console.WriteLine("*");
        }

        static void Main(string[] args)
        {
            // Call the method here
            displayTriangle();
        }
    }
} 
      

Все було зрозуміло?

Секція 6. Розділ 3
course content

Зміст курсу

C# Basics

Methods Creation PracticeMethods Creation Practice

Following is a code for outputting a triangle shape using multiple Console.WriteLine statements:

cs

main.cs

Create a new method called displayTriangle with the above code and call it in the main function.

cs

main.cs

1. Create a method using static void methodName() syntax and put the triangle code inside it.
Afterwards, execute it in the main method.

using System;

namespace ConsoleApp
{
    internal class Program
    {
        // Create a method here
        static void displayTriangle()
        {
            Console.WriteLine("*********");
            Console.WriteLine("*******");
            Console.WriteLine("*****");
            Console.WriteLine("***");
            Console.WriteLine("*");
        }

        static void Main(string[] args)
        {
            // Call the method here
            displayTriangle();
        }
    }
} 
      

Все було зрозуміло?

Секція 6. Розділ 3
some-alt