Курси /
C# Beyond Basics
Practicing Structs
Fill in the blanks to create a struct called Car
which has the following attributes:
name
of typestring
model
of typeint
mileage
of typefloat
Also fill in the blanks to complete the output statement.
index.cs
1. Use the
2. We use the
public
keyword before the fields in the structure definition.2. We use the
variableName.fieldName
syntax for accessing the fields and their data.
using System;
struct Car
{
public string name;
public int model;
public float mileage;
}
class Program
{
static void Main(string[] args)
{
Car car;
car.model = 2023;
car.name = "Hilux";
car.mileage = 2000;
Console.WriteLine($"The {car.name} has a mileage of {car.mileage} miles.");
}
}
Все було зрозуміло?
Секція 2. Розділ 3
Зміст курсу
C# Beyond Basics
C# Beyond Basics
Practicing Structs
Fill in the blanks to create a struct called Car
which has the following attributes:
name
of typestring
model
of typeint
mileage
of typefloat
Also fill in the blanks to complete the output statement.
index.cs
1. Use the
2. We use the
public
keyword before the fields in the structure definition.2. We use the
variableName.fieldName
syntax for accessing the fields and their data.
using System;
struct Car
{
public string name;
public int model;
public float mileage;
}
class Program
{
static void Main(string[] args)
{
Car car;
car.model = 2023;
car.name = "Hilux";
car.mileage = 2000;
Console.WriteLine($"The {car.name} has a mileage of {car.mileage} miles.");
}
}
Все було зрозуміло?
Секція 2. Розділ 3