Skip to content

Instantly share code, notes, and snippets.

@chuwilliamson
Last active February 3, 2024 15:20
Show Gist options
  • Save chuwilliamson/5363cb454a772830e732 to your computer and use it in GitHub Desktop.
Save chuwilliamson/5363cb454a772830e732 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Student
{
private string name;
private int age;
public Student(string n, int a)
{
name = n;
age = a;
}
public void Print()
{
Console.WriteLine("Name: " + name + " Age:" + age);
}
}
class Program
{
static void Main(string[] args)
{
List<string> names = new List<string>() { "eric", "paul", "tran", "quinton", "dylan", "shelby", "zac" };
List<int> ages = new List<int>() { 18, 20, 20, 18, 20, 30, 25 };
List<Student> students = new List<Student>();
for (int i = 0; i < names.Count; i++)
{
students.Add(new Student(names[i], ages[i]));
}
foreach (Student s in students)
{
s.Print();
}
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment