本帖最后由 面朝大海,春暖 于 2013-10-6 15:11 编辑
如下代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
onePerson one = new onePerson("黎明","男",32);
Console.WriteLine(one.name,one.sex,one.age);
Console.ReadKey();
}
public struct onePerson
{
public string name;
public string sex;
public int age;
//成员函数
public void opp()
{
//内容
}
//构造函数
public void onePerson(string Name,string Sex,int Age)
{
name = Name;
sex = Sex;
age = Age;
}
}
}
}
上述代码不能声明构造函数,说成员名与封闭类型相同,怎么回事
|