Courses /
C# Basics
Practicing Array Declaration
Create an empty array called heights
of type float
and length (size) of 7
.
It's fine if you don't understand the code after the array declaration. It will make more sense in the next chapter.
main.cs
1. The syntax of declaring an empty array is
datatype[] arrayName = new datatype[size];
.
using System;
namespace ConsoleApp
{
internal class Program
{
static void Main(string[] args)
{
// Declare an array below this line
float[] heights = new float[7];
heights[5] = 181.9f;
Console.WriteLine(heights[5]);
}
}
}
Everything was clear?
Section 5. Chapter 2
Course Content
C# Basics
C# Basics
Practicing Array Declaration
Create an empty array called heights
of type float
and length (size) of 7
.
It's fine if you don't understand the code after the array declaration. It will make more sense in the next chapter.
main.cs
1. The syntax of declaring an empty array is
datatype[] arrayName = new datatype[size];
.
using System;
namespace ConsoleApp
{
internal class Program
{
static void Main(string[] args)
{
// Declare an array below this line
float[] heights = new float[7];
heights[5] = 181.9f;
Console.WriteLine(heights[5]);
}
}
}
Everything was clear?
Section 5. Chapter 2