Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace quickstart {
- class Program {
- static void Main(string[] args) {
- WorkingWithStrings();
- var fibonacciNumbers = new List<int> {1, 1};
- while (fibonacciNumbers.Count < 20) {
- var previous = fibonacciNumbers[fibonacciNumbers.Count - 1];
- var previous2 = fibonacciNumbers[fibonacciNumbers.Count - 2];
- fibonacciNumbers.Add(previous + previous2);
- }
- foreach (var item in fibonacciNumbers)
- Console.WriteLine(item);
- }
- public static void WorkingWithStrings() {
- var names = new List<string> {"Wheelfox", "Roadhog", "Junkrat"};
- foreach (var name in names) {
- Console.WriteLine($"Hello, {name.ToUpper()}!");
- }
- Console.WriteLine();
- names.Add ("Enginehawk");
- names.Add ("Tirebear");
- names.Remove ("Wheelfox");
- foreach (var name in names) {
- Console.WriteLine($"Hello, {name.ToUpper()}!");
- }
- Console.WriteLine($"My name is {names[0]}!");
- Console.WriteLine($"I've added {names[2]} and {names[3]} to the list!");
- Console.WriteLine($"The list has {names.Count} people in it.");
- var index = names.IndexOf("Junkrat");
- Console.WriteLine($"The name {names[index]} is at index {index}.");
- var notFound = names.IndexOf("Not Found");
- Console.WriteLine($"When an item is not found, IndexOf returns {notFound}.");
- names.Sort();
- foreach (var name in names) {
- Console.WriteLine($"Hello, {name.ToUpper()}!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement