//所有的类都继承Object类;
Object a=3; 
Object b="ddfasfda";
//正常情况下,都会省略掉:Object;但实际上是存在的;
class test:Object
{

}

 

//自定义异常
throw new Exception("这个东东出错了!");
//抛出异常
Console.Write(ex.Message);

 

class Person
{
public static int TotalCount;
public int Age;
public static void 人口汇报()
{
//Console.WriteLine("我的年龄{0},全球总人口:{1}",Age,TotalCount);
//会报错,因为在static成员中不能直接调用非static成员;
}
public void SayHello()
{
Console.WriteLine("我的年龄{0},全球总人口:{1}",Age,TotalCount);
//在非static成员中可以直接调用static成员;
}
}
string s="";//空字符串,但不是null
string ss=null;//null表示没有指向对象,什么都没有;
int i=null;//int变量的值是不能为null的;
//可空(null)数据类型:引用类型,自定义类、string,
//不可空:值类型。int、boolean、decimal、DateTime等;
int? i1=null;在不可Null类型后加?就可以为null; 

 

相关文章:

  • 2021-07-10
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
  • 2022-01-08
  • 2021-05-28
  • 2021-12-22
猜你喜欢
  • 2021-12-06
  • 2021-10-04
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
相关资源
相似解决方案