static void BookList(string category,int pageIndex = 1)
{
//操作
}
//调用
static void Main(string[] args)
{
BookList("C#"); //使用全部默认参数
BookList("C#",2) //不使用默认参数
}
static void BookList(string category,int pageIndex = 1)
{
//操作
}
//调用
static void Main(string[] args)
{
BookList(category:"C#"); //使用全部默认参数
BookList(category:"C#",pageIndex:2) //不使用默认参数
}
var list = new Student(); //Student为自定义类型
var stu = new {Name="张三",Age=18,Gender="男"};
//创建1个动态类型对象
dynamic person1 = new Student{Name="Bing",Age=20};
person1.Introduce();
System.Nullable<int> num = null;
System.Nullable<DateTime> birthday = null;
//或
int? num = null;
DateTime? birthday = null;
eg:int? num = null; int num2 = num;
int? num1 = 5
int num2 = num1??0;
[Obsolete] //这个方法可用使用 但是编译时会警告
[Obsolete("不要使用旧的方法,使用新的方法",false)] //这个方法可用使用 但是编译时会警告
[Obsolete("不要使用旧的方法,使用新的方法",true)] //这个方法不可以使用,编译时会报错
static void Old(){
Console.WriteLine("这是旧方法!");
}
static void New(){
Console.WriteLine("这是新方法!");
}
public static void Main(){
Old();
}
[AttributeUsage(AttributeUsages.Class|AttributeUsages.Method,AllowMultiple=true)]
[AttributeUsage(AttributeUsages.Class)] //只能在类中进行使用
[AttributeUsage(AttributeUsages.Method)] //只能在方法中进行使用
[AttributeUsage(AllowMultiple=true)] //可以在同一个类上进行多次使用
class DescriptionAttribute:Attribute{
public string name{get;set;}
public DescriptionAttribute(){}
public DescriptionAttribute(string name){
this.name = name
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有