Skip to content

Instantly share code, notes, and snippets.

@CasonBarnhill
Created October 19, 2015 21:57
Show Gist options
  • Save CasonBarnhill/f671a86eebee413a4025 to your computer and use it in GitHub Desktop.
Save CasonBarnhill/f671a86eebee413a4025 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Week1Day1
{
class Program
{
static void Main(string[] args)
{
// Assign "Hello World" to a variable message
string message = "Hello World";
// Assign a different string to a different variable
string secondMessage = message;
// Assign a number to a variable
int age = 34;
// Use string interpolation to display the number in a string
// i.e. string interpolation = "Hello {0}"
string hello = string.Format("Hello {0}", age);
// Make an array of your favorite movies or books or bands. Have at least 4 values.
string[] casonFavoriteBands = { "aerosmith", "gunsNRoses", "motleyCrue", "theBeatles" };
// Make a anonymous type object of information about yourself. Have at least 4 properties on the anoymous type
var casonAttributes = new
{
casonMovement1 = "talk",
casonMovement2 = "walk",
casonAction1 = "think",
casonAction2 = "sleep",
};
// BONUS 1
// Make an array of anonymous types containing more information
// about your favorite movies. The type should have at least 3 keys+values
var movies = new[] {
new { Type = "Exciting", Time = "2hours", Name = "Gone in Sixty Seconds" },
new { Type = "Scary" , Time = "2.5hours", Name = "Texas Chainsaw Massascre" },
new { Type = "Funny" , Time = "1.5hours" , Name= "Taladega Nights" },
};
// BONUS 2
// Use 'for loop' and loop through the array of anonymoous types and print only one of the properties
// For example { firstname = "Jimbob" } loop through and print only the firstname
for (int i = 0; i < movies.Length; i++)
{
string cool = movies[i].Type;
Console.WriteLine(cool);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment