struct T_ChildStruct
创新互联主要从事成都做网站、成都网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务安源,十年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792
{
int nChildData;
string strChildData;
T_ChildStruct()
{
nChildData = 0;
strChildData = ""; // string可以不用写初始化,本身构造中就有
}
};
struct T_FatherStruct
{
int nFatherData;
string strFatherData;
T_ChildStruct arrChild[10];
T_FatherStruct()
{
nFatherData = 0;
strFatherData = "";
}
};
VB.NET ,结构体要写在所有函数的外部
Public Class Form1
Structure Hate
Dim str As String
Dim i As Integer
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As Hate
a.str = "string"
a.i = 1
MsgBox(a.str a.i)
End Sub
End Class
1、先定义一个结构体
2、初始化并定义一个结构体的变量
3、使用该变量即可