C# array of objects tutorial example explained
#C# #array #objects
using System;
namespace MyFirstProgram
{
class Program
{
static void Main(string[] args) {
Car[] garage = { new Car("Mustang"), new Car("Corvette"), new Car("Lambo") };
foreach (Car car in garage)
{
Console.WriteLine(car.model);
}
Console.ReadKey();
}
}
class Car
{
public String model;
public Car(String model)
{
this.model = model;
}
}
}
#C# #array #objects
using System;
namespace MyFirstProgram
{
class Program
{
static void Main(string[] args) {
Car[] garage = { new Car("Mustang"), new Car("Corvette"), new Car("Lambo") };
foreach (Car car in garage)
{
Console.WriteLine(car.model);
}
Console.ReadKey();
}
}
class Car
{
public String model;
public Car(String model)
{
this.model = model;
}
}
}
- Category
- Bro Code
- Tags
- C# (Programming Language), Programming Language (Software Genre), Arrays

Be the first to comment