Course Content
C# Basics
C# Basics
Methods Creation Practice
Following is a code for outputting a triangle shape using multiple Console.WriteLine
statements:
main.cs
Create a new method called displayTriangle
with the above code and call it in the main function.
main.cs
1. Create a method using
Afterwards, execute it in the
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();
}
}
}
Everything was clear?
Section 6. Chapter 3
Course Content
C# Basics
C# Basics
Methods Creation Practice
Following is a code for outputting a triangle shape using multiple Console.WriteLine
statements:
main.cs
Create a new method called displayTriangle
with the above code and call it in the main function.
main.cs
1. Create a method using
Afterwards, execute it in the
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();
}
}
}
Everything was clear?
Section 6. Chapter 3