36
1
using System;
2
3
public class Program
4
{
5
struct Book
6
{
7
public string title;
8
public double price;
9
public string author;
10
}
11
12
struct Coords
13
{
14
public int x;
15
public int y;
16
17
// constructor
18
public Coords(int p1, int p2) {
19
x = p1;
20
y = p2;
21
}
22
}
23
24
public static void Main()
25
{
26
Book myFavBook;
27
myFavBook.title = "The Fellowship of the Rings";
28
myFavBook.author = "J.R.R. Tolkien";
29
myFavBook.price = 29.99;
30
31
Coords point = new Coords(42, 69);
32
33
Console.WriteLine(myFavBook.title); // outputs: "The Fellowship of the Ring"
34
Console.WriteLine("x = {0}, y = {1}", point.x, point.y); // outputs: x = 42, y = 69
35
}
36
}
Cached Result