C# 12 new feature Collection Expression,Primary Consctructor,Generic type alias,
using listOfInt = System.Collections.Generic.List<int>; namespace ConsoleApp36 { internal class Program { static void Main(string[] args) { GenericTypeAlias(); } static void GenericTypeAlias() { var list = new listOfInt(); for(int i=0;i<100;i++) { list.Add(i*i); } for(int i=0;i<100; i++) { Console.WriteLine(list[i]); } } static void DefaultLambdaExpressionDemo() { var defaultLambdaExpression = (string time = "") => Console.WriteLine(time); defaultLambdaExpression("time now"); } static void CollectionExpression() { char[] vowels = ['a', 'e', 'i', 'o', 'u']; foreach (var ch in vowels) { Console.WriteLine(ch); } List<int> list = [10, 20, 30, 40, 50, 60, 70]; foreach(var i in list) { Console.WriteLine(i); } } static void PrimaryConstrutorDemo() { PrimaryConstructor pc = new PrimaryConstructor(1, "test"); pc.Print(); } } class PrimaryConstructor(int id,string name) { public void Print() => Console.WriteLine($"Id:{id},Name:{name}"); } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2023-06-05 cpp test write content speed to ssd and usual disk respectively 1M,10M,100M rows data,the fact has illustrated the write speed of ssd is 4-5 times faster than usual disk
2023-06-05 c++ condition_variable wait unique_lock,cv.notifyall()
2023-06-05 c++ tree data structure
2020-06-05 C# deflatestream compress and decompress, compare their respective md5
2020-06-05 C# BinaryWriter BinaryReader demo
2019-06-05 C# NPOI Export DataTable C# NPOI导出DataTable 单元格自适应大小