Hi there, so im trying to get something done for my class. Im supposed to implement something where you can enter details of a person, validate them, then store them as a array, and allow you to add more later. What I dont understand is how to store a group of variables (ie. Name, phone number, postcode) in one array and when another record is added, simply add it on, without erasing the contents of the previous record.
I hope ive asked this in the correct place. Was just hoping for a bit of help, as all tutorials oh the internet only seem to cover entering pre-made data into arrays.
Thanks
elliot81
-2
Newbie Poster
Recommended Answers
Jump to Postuse generics...
List<string> personsData = new List<string>(); string personData = "name,phone,number,postcode"; personsData.Add(personData); //use System.IO.File class to store personsData content...
Jump to PostIf you're newbie.. please read in generics, arrays, and files
Generics http://msdn.microsoft.com/en-us/library/512aeb7t(VS.80).aspx
Arrays http://msdn.microsoft.com/en-us/library/aa288453(VS.71).aspx
File
Jump to PostYou should add a new class Person and use a generic list.
Here's an example:
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication { class Program { static void Main(string[] args) { [B]List<Person> people = new List<Person>();[/B] string salary, pno, pcode, state, addr, strno, name; Console.WriteLine("enter …
Jump to PostThanks for the tip, but for this we have been told specifically to use arrays rather then lists. Would you mind posting the array equivalent? :)
static void Main(string[] args) { int select = 0; const int MAX_PEOPLE=10; string[][]people = new string[MAX_PEOPLE][]; int count = 0; while …
All 13 Replies
Ramy Mahrous
401
Postaholic
Featured Poster
elliot81
-2
Newbie Poster
Ramy Mahrous
401
Postaholic
Featured Poster
elliot81
-2
Newbie Poster
farooqaaa
48
Enthusiast
elliot81
-2
Newbie Poster
farooqaaa
48
Enthusiast
elliot81
-2
Newbie Poster
kvprajapati
1,826
Posting Genius
Team Colleague
elliot81
-2
Newbie Poster
kvprajapati
commented:
Purchase some good books and learn c#!!!
-2
kvprajapati
1,826
Posting Genius
Team Colleague
elliot81
-2
Newbie Poster
kvprajapati
1,826
Posting Genius
Team Colleague
Ramy Mahrous
commented:
Patient :)
+6
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.