How can I change System.String [] in string

0

I have an application that returns a user but the output is System.String[] would like me to give me the real value of the array.

How can I do this?

Here is my code of the way I passed the parameters.

Thanks

UserData[] userDataId = GetUserData(DataSourceId);

List<string> multiUserIDs = new List<string>();

if (userDataId.Length > 0)                
{

    foreach (var userdata in userDataId)
    {
        multiUserIDs.Add(userdata.List[0].ToString());   //esto me devuelve la lista de array como System.String[]                      
    }
}

By making the changes and adding multiUserIDs.Add(String.Join(",", userdata.List[0])); the output appears to me as System.Collections.Generic.List 1 [System.String] '

This appears to me when the result is written in a .CPDF file in the following way:

ReportEntry[] report = db.GetReports(multiUserIDs.ToArray());
for (int i = 0; i < report.Length; ++i)
{
    textBox1.Text += 
    "ReportID: " + report[i].ReportID + "\r\n" +
    "ReportTitle: " + report[i].ReportTitle + "\r\n" +
    "Link: " + siteUrl + System.IO.Path.GetFileName(report[i].Link);

    string outCsvFile = string.Format(@"C:\ReportsPDF\{0}.pdf", multiUserIDs.ToString() + "_" + report[i].ProjectTitle);

}

Where the problem is that the file is created after the next execution

string outCsvFile = string.Format(@"C:\ReportsPDF\{0}.pdf", multiUserIDs.ToString() + "_" + report[i].ProjectTitle);
    
asked by A arancibia 01.04.2016 в 23:02
source

4 answers

2

Well I could do it in the following way:

in the multiUserIDs variable, I did it like this:

multiUserIDs.Add(String.Join(",", userdata.List[0]));

In the final output I can do it like this:

string outCsvFile = string.Format(@"C:\ReportsPDF\{0}.pdf", String.Join(",", userdata.List[0]) + "_" + report[i].ProjectTitle);

Thanks to everyone again!

    
answered by 07.04.2016 в 22:56
0

Assuming that your userID are in index 0 of the lists, you can use userdata.ElementAt(0) :

 foreach (var userdata in userDataId)
    {
        multiUserIDs.Add(userdata.ElementAt(0).ToString());   
    }
    
answered by 02.04.2016 в 01:39
0

Be something like

foreach (var userdata in userDataId)
{
    foreach(var item in userdata.List){
         multiUserIDs.Add(item.ToString());
    }   
}

This way you go through the userData list and then the list of ids that you assign to the string list

> > > I need to get in the result List [0] that this gives me the userID of the list that is in position 0. This userID as I put in the multiUserIDs returns the array.

I understand that the List [] is another entity that has the property userID, if so, you could use

foreach (var userdata in userDataId)
{
    multiUserIDs.Add(userdata.List[0].userID.ToString());      
}
    
answered by 01.04.2016 в 23:07
-1

Maybe using String.Join(",", userdata.List)

    
answered by 02.04.2016 в 00:23