Well
you can't do that.
If you might have noticed, Class is a template, that allow us to instantiate objects from it.
It
doesn't allow us to persist something. It is just a Signature or as I said, Template.
With the help of this template you can create instances of it, call methods of it, and/or may use static variables/functions of it. But still you can't hold data on it.
Well yeah, you can certainly store data somewhere i.e Text Files, Databases etc using Class.
So the solution towards your problem is, create a class, which can have certain properties that you need i.e Id, Name etc.
If you're not using any data storage, then you can store these data on
List<t></t>
, or
Arrays
etc., and use it.
Like,
List<Student> studs = new List<Students>();
studs.Add(new Student {Id = 1, Name = "AAA"});
studs.Add(new Student {Id = 2, Name = "BBB"});
studs.Add(new Student {Id = 3, Name = "CCC"});
and if you want to get the data of Student, which has Id=1 then,
Student s = studs.Find(s => s.Id == 1);
Console.Write(s.Name);
Rather I'd suggest you to go for
Databases. :)
-KR