TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prashant Jadhav
NA
38
14.2k
list collection working
Aug 3 2014 7:14 AM
hi guys i was interested to know how list collection work and i tried to create my own collection like list please guide me if this could the way that list collection would have been created .its obvious that original list class must have huge coding.
using System;
namespace ConsoleApplication12
{
class customer
{
public string name;
public int custID;
}
class MyList<T>
{
public T[] MyListElement = new T[3];
private int index=0;
public void Add(T cust)
{
if (index == MyListElement.Length)
{
Array.Resize<T>(ref MyListElement,MyListElement.Length+3);
MyListElement[index] = cust;
index ++;
return;
}
MyListElement[index] = cust;
index ++;
}
}
class Program
{
static void Main(string[] args)
{
customer c = new customer() {name="prashant",custID=2 };
customer c1 = new customer() { name = "amit", custID = 3 };
customer c2 = new customer() { name = "ajit", custID = 4 };
customer c3 = new customer() { name = "pritesh", custID = 5 };
customer c4 = new customer() { name = "jo", custID = 33 };
customer c5 = new customer() { name = "ko", custID = 43 };
customer c6 = new customer() { name = "do ", custID = 53 };
customer c7 = new customer() { name = "fo", custID = 53 };
MyList<customer> customers = new MyList<customer>();
customers.Add(c);
customers.Add(c1);
customers.Add(c2);
customers.Add(c3);
customers.Add(c4);
customers.Add(c5);
customers.Add(c6);
customers.Add(c7);
Console.WriteLine(customers.MyListElement.Length);
Console.ReadLine();
}
}
}
Reply
Answers (
3
)
How to generate the xml nodes programatically?
indexer