class MyClass
{
public int Age { get; set; }
public string Name { get; set; }
public MyClass()
{
Age = 20;
Name = "张三";
}
}
class MyClass
{
public int Age { get; set; } = 20;
public string Name { get; set; } = "张三";
}
class MyClass
{
public void MyMethod()
{
string name = "张三";
int age = 20;
string s1 = string.Format("{0},{1}", name, age);
string s2 = string.Format("姓名={0},年龄={1}", name, age);
string s3 = string.Format("{0,15},{1:d3}", name, age);
string s4 = string.Format("{0,15},{1,10:d3}", name, age);
Console.WriteLine("{0},{1},{2},{3}", s1, s2, s3 ,s4);
string s5 = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
class MyClass
{
public void MyMethod()
{
string name = "张三";
int age = 20;
string s1 = $"{name},{age}";
string s2 = $"姓名={name},年龄={age}";
string s3 = $"{name,15},{age:d3}";
string s4 = $"{name,15},{age,10:d3}";
Console.WriteLine($"{s1},{s2},{s3},{s4}");
string s5 = $"{DateTime.Now:yyyy-MM-dd}";
}
}
class MyClass
{
public void MyMethod()
{
Dictionary<string, int> student = new Dictionary<string, int>();
student.Add("a1", 15);
student.Add("a2", 14);
student.Add("a3", 16);
}
}
class MyClass
{
public void MyMethod()
{
Dictionary<string, int> student = new Dictionary<string, int>()
{
["a1"] = 15,
["a2"] = 14,
["a3"] = 16
};
}
}
using System;
namespace MyApp
{
class Demo1New
{
public static double MyMethod(double x, double angle)
{
return Math.Sin(x) + Math.Cos(angle);
}
}
}
using static System.Math;
namespace MyApp
{
class Demo1New
{
public static double MyMethod(double x, double angle)
{
return Sin(x) + Cos(angle);
}
}
}
public class MyClass
{
public string MyText { get; set; } = "aaa";
}
var ss = new string[] { "Foo", null };
var length0 = ss [0]?.Length; // 结果为3
var length1 = ss [1]?.Length; // 结果为null
var lengths = ss.Select (s => s?.Length ?? 0); //结果为[3, 0]
async void SomeMethod()
{
try
{
//...etc...
}
catch (Exception x)
{
var diagnosticData = await GenerateDiagnosticsAsync (x);
Logger.log (diagnosticData);
}
finally
{
await someObject.FinalizeAsync();
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有