C#结构体特性实例分析

2019-12-26 13:31:46王冬梅
  • {  public static int a = 10; 
  • };  } 
  • class exe  { 
  • public static void Main()  { 
  • Console.WriteLine( base.student.a = 100);  } 
  • }; 

    在结构体中可以定义构造函数以初始化成员,但不可以重写默认无参构造函数和默认无参析构函数

    程序:

     

     
    1. public struct student  { 
    2. public int x;  public int y; 
    3. public static int z;  public student(int a,int b,int c) 
    4. {  x=a; 
    5. y=b;  student.z=c; 
    6. }  }; 

    在结构体中可以定义成员函数。

    程序:

     

     
    1. public struct student  {