0

hi,

I need to copy a dictionary to another dictionary where the Dictionary contains class data as value for eg I want to copy the data of object A1 to A2 .Thanks for your time.

Class A
{
}
Class B
{
}
Main()
{

Dictionary<int,A> A1 = new Dictionary<int,A>(); // first dictionary obj
Dictionary<int,B> A2 = new Dictionary<int,B>(); // Second dictionary obj

}
2
Contributors
1
Reply
13
Views
2 Years
Discussion Span
Last Post by cgeier
0

What are you trying to accomplish? You need to provide more detail, such as some variable names and data types to make it easier to see what you are trying to accomplish.

Obviously, there would be no point to doing the following:

public class A
{
    public string firstName = string.Empty;
    public string lastName = string.Empty;
}//A

public class B
{
    public string firstName = string.Empty;
    public string lastName = string.Empty;
}//B

However, at times, inheritance may be of use:

public class A
{
    public string firstName = string.Empty;
    public string lastName = string.Empty;
}//A

public class B : A
{
    public string streetName = string.Empty;
    public string zipCode = string.Empty;
}//B

Edited by cgeier

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.