defining an object in C# code example
Example 1: c# create new object
Car mycar = new Car();
Example 2: c# objects
using System;
class Book
{
public string title;
public string author;
public int pages;
}
class MainClass {
public static void Main (string[] args) {
Book book1 = new Book();
book1.title = "Harry Potter";
book1.author = "JK Rowling";
book1.pages = 400;
Console.WriteLine(book1.title);
}
}
Example 3: c# new object
//Declaring a new object of type Galaxy.
Galaxy aGalaxy = new Galaxy();