Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, int> inventory = new Dictionary<string, int>();
- inventory.Add("apple", 3);
- inventory.Add("orange", 5);
- inventory.Add("banana", 2);
- foreach (KeyValuePair<string, int> entry in inventory)
- {
- Console.WriteLine(entry);
- }
- string firstName = "Michael";
- string lastName = "Gallego";
- int age = 22;
- string phrase = String.Format("{0} {1} is the age of {2}", firstName, lastName, age);
- Console.WriteLine(phrase);
- for (int i = 0; i < 10; i++)
- {
- if (i % 2 != 0)
- {
- Console.WriteLine(i);
- }
- }
- Console.WriteLine(Division(5, 2));
- AnotherClass car1 = new AnotherClass(4, 2004, true);
- AnotherClass car2 = new AnotherClass(3, 2007, false);
- AnotherClass car3 = new AnotherClass(2, 2013, true);
- List<AnotherClass> cars = new List<AnotherClass>();
- cars.Add(car1);
- cars.Add(car2);
- cars.Add(car3);
- foreach (AnotherClass car in cars)
- {
- Console.WriteLine(car);
- }
- Console.ReadKey();
- }
- public static float Division(int x, int y)
- {
- float divisionNumber = 0;
- divisionNumber = (float) x / (float) y;
- return divisionNumber;
- }
- }
- class AnotherClass
- {
- int numTires;
- int year;
- bool runs;
- public AnotherClass(int numTires, int year, bool runs)
- {
- this.numTires = numTires;
- this.year = year;
- this.runs = runs;
- }
- public override string ToString()
- {
- if (runs)
- {
- return String.Format("This car runs, has {0} number of tires, and the year of the model is {1}", numTires, year);
- } else
- {
- return String.Format("The car does not run, but has {0} number of tires, and the year of the model is {1}", this.numTires, this.year);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment