Created
April 18, 2015 20:27
-
-
Save sampritipanda/ba6917c2297f1d322004 to your computer and use it in GitHub Desktop.
Structs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Structs | |
{ | |
public struct Menu | |
{ | |
private Coffee[] coffees; | |
public Menu(string name) | |
{ | |
Coffee coffee1 = new Coffee(name, 0); | |
coffees = new Coffee[1] { coffee1 }; | |
} | |
public Coffee this[int index] | |
{ | |
get { return this.coffees[index]; } | |
set { this.coffees[index] = value; } | |
} | |
} | |
public struct Coffee | |
{ | |
public Coffee(string name, decimal price) | |
{ | |
this.Name = name; | |
this.Price = price; | |
} | |
public string Name { get; set; } | |
public decimal Price { get; set; } | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Menu menu1 = new Menu("Starbucks"); | |
Console.WriteLine(menu1[0].Name); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment