Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Structs | Structs & Enumerators
C# Object-Oriented Structures

bookChallenge: Structs

メニューを表示するにはスワイプしてください

Fill in the blanks to create a struct called Car which has the following attributes:

  1. name of type string;
  2. year of type int;
  3. mileage of type float.

Also fill in the blanks to complete the output statement.

index.cs

index.cs

copy
12345678910111213141516171819202122
using System; struct ___ { ___; ___; ___; } class Program { static void Main(string[] args) { Car car; car.model = 2023; ___ = "Hilux"; car.mileage = 2000; Console.WriteLine($"The {car.name} has a mileage of {___} miles."); } }
  1. Use the public keyword before the fields in the structure definition.
  2. Use the variableName.fieldName syntax for accessing the fields and their data.
index.cs

index.cs

copy
12345678910111213141516171819202122
using System; struct Car { public string name; public int year; public float mileage; } class Program { static void Main(string[] args) { Car car; car.year = 2023; car.name = "Hilux"; car.mileage = 2000; Console.WriteLine($"The {car.name} has a mileage of {car.mileage} miles."); } }
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 2.  3

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 2.  3
some-alt