1 Star 0 Fork 0

猪头痴人/LearnCSharp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
LearnCollection.cs 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
ronal 提交于 2021-11-08 21:10 . 学习代码更新。
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");
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ZhuTouChiRen/learn-csharp.git
git@gitee.com:ZhuTouChiRen/learn-csharp.git
ZhuTouChiRen
learn-csharp
LearnCSharp
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385