Z
Zach
On 12/17/2011 5:40 AM, Zach wrote:
I am sorry about yesterday. I set out with an indexer, like below. It
contains data. Suppose data were to be changed to "person", my question
was how I could ad say "job", for the code to be able to manipulate
both
person and job, rather than just person. I somehow got totally mind
boggled during the discussion with you guys, unable to deal with the
simplest code lines. I had said at the outset that I wasn't looking for
a container of employee-objects of some sort, with which I ended up.
Don't know what happened. It has been a jolly bad experience. I have
found it very difficult to be in a discussion where one wrong word
causes heaven to explode.
I provided an example showing what you could do to dual index.
But you did never even comment on that.
Thank you for drawing my attention to your post. I am afraid that I seem
to have spent yesterday in utter confusion. An unpleasant situation was
unfolding around me while I was working with you guys and I guess I lost
my nuts. You have put in a lot of effort to help, for which I thank you
sincerely, and I _apologize _for _not _responding, which is absolutely
"pas comme il faut".
In fact I did try your code, and got a long list of errors.
Line 79 onwards: "A new expression requires () or [] after type"
Line 8 E.Person.Name.get must declare a body because it is not marked
abstract or extern.
more similar to the previous line 8 error.
I have VS 2005, and it would appear that given VS 2010 is now in use, it
might be the VS that I am using, which is causing the errors. I think
you are using VS'10 syntax with which I am not yet familiar. Hence I am
finding it hard to figure out what you are doing. VS costs 1000€ in this
country, so I will have to have a good think about what to do next.
It is.
I am just lazy and initialized things the easiest way using .NET 3.5
features.
But the core can easily be converted back to .NET 2.0.
<snipped>
Hi Arne, I believe this is shorter
![Smile :) :)](/styles/default/custom/smilies/smile.gif)
does the same thing.
Zach
using System;
using System.Collections.Generic;
using System.Text;
namespace analysis1
{
class Program
{
static void Main(string[] args)
{
EmployeeList lst = new EmployeeList();
lst.Add(new Person("A A", "A road 123"));
lst.Add(new Job("Fitter", "10000$"));
lst.Add(new Person("B B", "B ave 456"));
lst.Add(new Job("Tester", "234567$"));
Console.WriteLine(lst.PersonRetrieve(0).PersonString());
Console.WriteLine(lst.JobRetrieve(0).JobString());
Console.WriteLine(lst.PersonRetrieve(1).PersonString());
Console.WriteLine(lst.JobRetrieve(1).JobString());
Console.ReadKey();
}
public class PersonList
{
private List<Person> people = new List<Person>();
public void Add(Person p) { people.Add(p); }
public Person this[int px] { get { return people[px]; }
set { people[px] = value; } }
public Person PersonRetrieve(int py) { return people[py]; }
}
public class JobList
{
private List<Job> jobs = new List<Job>();
public void Add(Job j) { jobs.Add(j); }
public Job this[int jx] { get { return jobs[jx]; }
set { jobs[jx] = value; } }
public Job JobRetrieve(int jy) { return jobs[jy]; }
}
public class Person
{
string name;
string address;
public Person(string name, string address)
{
this.name = name;
this.address = address;
}
public string PersonString()
{
return string.Format ("Name {0} Address {1}",
name, address);
}
}
public class Job
{
string title;
string salary;
public Job(string title, string salary)
{
this.title = title;
this.salary = salary;
}
public string JobString()
{
return string.Format("Title {0} Salary {1}",
title, salary);
}
}
public class EmployeeList
{
private PersonList persons = new PersonList();
public void Add(Person p)
{
persons.Add(p);
}
public Person PersonRetrieve(int arg)
{
return persons.PersonRetrieve(arg);
}
private JobList jobs = new JobList();
public void Add(Job j)
{
jobs.Add(j);
}
public Job JobRetrieve(int arg)
{
return jobs.JobRetrieve(arg);
}
}
}
}