Copying a single dimension array into a structure array

Hi, I've got a structure with multiple strings. I want to copy a string array into the structure array. Any suggestions? I don't want the string copied into all elements of the structure array, just the one I specify.

protected struct my_struct
{
    protected string string1;
    protected string string2;
    protected string string3;
}

protected void doSomeWork()
{
    string[] myStringArray = new string [5];
    my_struct[] myStructureArray = new my_struct[5];

    myStringArray[0] = "a";
    myStringArray[1] = "b";
    myStringArray[2] = "c";
    myStringArray[3] = "d";
    myStringArray[4] = "e";

//Here's basically where I'm stuck!
    Array.Copy(myStringArray, myStructArray.string1, 1);
}

Any help would be appreciated. I have a feeling this is something simple that I'm missing.
SoCalChrisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AaronReamsCommented:
Here's one way to do it...

string[] myStringArray = new string [5];
myStringArray[0] = "a";
myStringArray[1] = "b";
myStringArray[2] = "c";
myStringArray[3] = "d";
myStringArray[4] = "e";

my_struct myStructArray = new my_struct;
for(int i=0; i<5; i++)
     myStructArray.string1+=myStringArray[i];
0
AaronReamsCommented:
also the members of your struct need to be public.
0
SoCalChrisAuthor Commented:
Do you know how to do this without having to loop through each array item?
0
AaronReamsCommented:
Here's the other option... but you're copying an array to an array, not consolidating an array to one string.  is that what you want?

protected struct my_struct
{
    public string[] string1;
    public string[] string2;
    public string[] string3;
}

string[] myStringArray = new string [5];
my_struct[] myStructArray = new my_struct[5];
myStringArray[0] = "a";
myStringArray[1] = "b";
myStringArray[2] = "c";
myStringArray[3] = "d";
myStringArray[4] = "e";

myStructArray[0].string1 = new string[5];

//Here's basically where I'm stuck!
Array.Copy(myStringArray, myStructArray[0].string1, 1);

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.