Click here to Skip to main content
16,011,120 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if i got a class like this

C#
public class Node
        {
            public string Name { get; set; }
            int Duration { get; set; }
            string Prede { get; set; }

        }


and i want to inherit new objects (that is up to data i store)

i store data as a list >>>>> Project_Name[]

in list it may contain 1 - infinity up to user put it in

how can i inherit it : (

PS: if my english Suck i am sorry.
Posted
Comments
Kornfeld Eliyahu Peter 25-Feb-14 10:23am    
You may show more of your code to try and make the question better...

1 solution

Well, If I'm not mistaken then you're asking about getting data. Right ?
So, what you can do is,
C#
Node nd = new Node():
foreach(Node n in Project_Name)
{
    if(n.Name == "Some_Name")
    {
        nd.Name = n.Name;
        nd.Duration = n.Duration;
        // and so on...
    }
}


I hope this is it what you're after is. :)
-KR
 
Share this answer
 
Comments
Real_Criffer 25-Feb-14 12:32pm    
hx you very much how about we don't know "somename" sir


for (int X = 0; X <= dataGridView1.RowCount - 1; X++) // เก็บ ชื่อกิจกรรม ไว้ใน list
{

Proj_name = Convert.ToString(dataGridView1.Rows[X].Cells[0].Value);

Proj_name_Values.Add(Convert.ToString(Proj_name));
}
for (int X = 0; X <= dataGridView1.RowCount - 1; X++) // เก็บ duration ไว้ใน list
{

Duration = Convert.ToInt32(dataGridView1.Rows[X].Cells[1].Value);

Duration_Values.Add(Convert.ToInt32(Duration));
}

for (int X = 0; X <= dataGridView1.RowCount - 1; X++) // เก็บค่า predecessor ไว้ใน list
{

Predecessor = Convert.ToString(dataGridView1.Rows[X].Cells[2].Value);

String[] Word = Predecessor.Split(' ');

Predecessor_Number.Add(Convert.ToString(Word.Length));

Predecessor_Values.Add(Convert.ToString(Predecessor));

Predecessor_Value_FindLF.Add(Convert.ToString(Predecessor));
}
}

here is what i store everything

and i want each of it in a node do you have any idea?

PS: I am newbies in C#

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900