代码拉取完成,页面将自动刷新
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LearnCSharp_1
{
class LearnCollection
{
static void Main_Collection(string[] args)
{
var names = new List<string> { "<name>", "Ana", "Felipe" };
foreach (var name in names)
{
Console.WriteLine($"Hello {name.ToUpper()}");
}
Console.WriteLine($"My name is {names[0]}.");
Console.WriteLine($"I've added {names[1]} and {names[2]} to the list.");
Console.WriteLine($"The list has {names.Count} people in it.");
Console.ReadKey();
var index = names.IndexOf("Felipe");
if (index != -1)
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()}!");
}
Console.ReadKey();
var fibonacciNumbers = new List<int> { 1, 1 };
var previous = fibonacciNumbers[fibonacciNumbers.Count - 1];
var previous2 = fibonacciNumbers[fibonacciNumbers.Count - 2];
fibonacciNumbers.Add(previous + previous2);
foreach (var item in fibonacciNumbers)
Console.WriteLine(item);
Console.ReadKey();
}
public static void test_array_list()
{
ArrayList arrayList = new ArrayList();
arrayList.Add(123);
arrayList.Add("abc");
arrayList.Insert(1, 123 + "abc");
arrayList.RemoveAt(1);
}
public static void test_dictionary()
{
Dictionary<int, string> dictionary = new Dictionary<int, string>();
dictionary.Add(1, "98");
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。