stefan1919

Working With Arrays, Enumerations, and Structures

Oct 31st, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ModuleThreeAssignment
  8. {
  9.     class Program
  10.     {
  11.         enum Days { Monday, Thursday, Wednesday, Thuesday, Friday, Saturday, Sunday };
  12.         //struct Coffee
  13.         //{
  14.         //    public string grind;
  15.         //    public string Name { get; set; }
  16.         //    public string Bean { get; set; }
  17.         //    public string CountryOfOrigin { get; set; }
  18.         //    public int Strength { get; set; }
  19.         //}
  20.  
  21.         //Create a constructor in a struct
  22.         //public struct Coffee
  23.         //{
  24.         //    // This is the custom constructor.
  25.         //    public Coffee(int strength, string bean, string countryOfOrigin)
  26.         //    {
  27.         //        this.Strength = strength;
  28.         //        this.Bean = bean;
  29.         //        this.CountryOfOrigin = countryOfOrigin;
  30.         //    }
  31.         //    // These statements declare the struct fields and set the default values.
  32.         //    public int Strength;
  33.         //    public string Bean;
  34.         //    public string CountryOfOrigin;
  35.         //    // Other methods, fields, properties, and events.
  36.         //}
  37.         static void Main(string[] args)
  38.         {
  39.             //Working With Arrays
  40.             //int[] array = new int[10];
  41.             //int[] simple;
  42.             //int[] newArray = { 10, 20, 30, 40 };
  43.             //int[,] twoDArray = { { 3, 2 }, { 4, 1 }, { 5, 5 } };
  44.             //for (int rows = 0; rows < twoDArray.GetLength(0); rows++)
  45.             //{
  46.             //    for (int cols = 0; cols < twoDArray.GetLength(1); cols++)
  47.             //    {
  48.             //        Console.Write(twoDArray[rows, cols]);
  49.             //    }
  50.             //    Console.WriteLine();
  51.             //}
  52.  
  53.  
  54.             ////Working With Enumerations
  55.             //int x = (int)Days.Monday;
  56.             //Console.WriteLine("Monday = {0}", x);
  57.             //int y = (int)Days.Sunday;
  58.             //Console.WriteLine("Sunday = {0}", y);
  59.             ////Output:
  60.             ////0
  61.             ////7
  62.  
  63.             //Working With Structures
  64.             //Coffee coffee1 = new Coffee();
  65.             //coffee1.Name = "Fourth Coffee Quencher";
  66.             //coffee1.CountryOfOrigin = "Indonesia";
  67.             //coffee1.Strength = 3;
  68.             //coffee1.grind = "Fine";
  69.             //Console.WriteLine("Name {0}", coffee1.Name);
  70.             //Console.WriteLine("Country of Origin {0}", coffee1.CountryOfOrigin);
  71.             //Console.WriteLine("Strength {0}", coffee1.Strength);
  72.             //Console.WriteLine("Grind: {0}", coffee1.grind);
  73.  
  74.  
  75.             ////Calling a constructor struct
  76.             //Coffee coffee1 = new Coffee(4, "Arabica", "Colombia");
  77.             //Console.WriteLine(coffee1.CountryOfOrigin);
  78.             ////Colombia
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment