• unity3d C# 調(diào)用C程序封裝結(jié)構(gòu)體函數(shù)

    2023/10/30??????點(diǎn)擊:

    C#程序定義結(jié)構(gòu)圖的方式如下:

    public struct student  //結(jié)構(gòu)體名
    {
            //沒(méi)有public 修飾的成員變量 不能被訪問(wèn)
    	 public string Name;
             public string Sex;
    	 public int Age;
             public  student(string name, string sex, int age)
             {
                   this.Name = name;
                   this.Sex = sex;
                   this.Age = age;
              }          
    }

    如果結(jié)構(gòu)體內(nèi)定義了靜態(tài)成員或者函數(shù), 則調(diào)用時(shí)只會(huì)被初始化次, 如:

    static student()
    {
                 Console.WriteLine("我是靜態(tài)函數(shù)");
    } 
    結(jié)構(gòu)體實(shí)例化方法:
    student boy1 = new Student("小明","男", 18); 
    student boy2 = boy1;