Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,


I am vino, I am fresher of silverlight 2. I want to combine two list array in silverlight 2 .. please any one help ...


Give simple example


This is my code . . .

List Array 1
------------

public class A
{
public A(string Aname)
{
ANAME = Aname;
}

public string ANAME { get; set; }
}

public static List alist

List Array 2
-----------


C#
public class B
{
    public B(string Bname)
    {
        BName = Bname;
    }
    public string BName { get; set; }
}

public static List blist;


how to combine the list array A and B in single listarray and how it use in silverlight 2..

please guide me
Posted

1 solution

If you use a generic List<T>, you cannot combine "class A" with "class B".
You can build a Base class for "class A" and "class B".

C#
public class Base
{
  public string Name { get; set; }
}

public class A : Base
{
}

public class B : Base
{
}


List<base> aList = new List<base>;
aList.Add(new A { Name = "From Class A - 1" });
aList.Add(new A { Name = "From Class A - 2" });


List<base blist="new">;
bList.Add(new B { Name = "From Class B - 21" });
bList.Add(new B { Name = "From Class B - 22" });

// Combine aList and bList
List<base> abList = new List<base>;
abList.AddRange(aList);
abList.AddRange(bList);
 
Share this answer
 
v2

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