怎么使用带参构造函数来实现多个对象的初始化
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
student s1 = new student();
student s2 = new student();
student s3 = new student();
Console.WriteLine(s1.name);
Console.WriteLine(s1.age);
Console.WriteLine(s2.name);
Console.WriteLine(s2.age);
Console.WriteLine(s3.name);
Console.WriteLine(s3.age);
Console.ReadLine();
}
}
public class student
{
public string name;
public int age;
public student(string n, int a)//构造函数
{
age = a; //我想知道a和n怎么使用
name = n;
}
}
}