Link to home
Start Free TrialLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

asked on

c#, split

List<string> licenseDocList = new List<string>();
            foreach (string value in ViewLicenseDocumentList(76))
            {
                licenseDocList.Add(value);
            }

I want to see below output from above. how can i do  that?
Basically Convert List<string> to String[]

 //String[] files = @"F:\My Hard A.pdf, B.pdf".Split(',');
Avatar of kaufmed
kaufmed
Flag of United States of America image

Call ToArray against the list.
If you convert your list to a string array  you still need to convert your array to text in order to view it.
You can do like here:
string combindedString = string.Join( Environment.NewLine, licenseDocList.ToArray() );// print every element from new line

Open in new window


Just replace Environment.NewLine with a delimiter you want...
Avatar of Micheal Autry
Micheal Autry

List<string> will always be more efficient than string[]
I would stick with your List<string>

Not too clear on what you want your output to look like or what your input looks like.  But once you've populated your licenseDocList object with the data as you have, you can just run is through another foreach to get the data back out.  If you provide some sample input such as what value looks like when it gets added to your list along with a better example of what your are trying to achieve I can provide a more concise solution for you.

foreach( string license in licenseDocList )
{
    Console.WriteLine( license );
}
ASKER CERTIFIED SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Micheal Autry
List<string> will always be more efficient than string[]
Unless you quantify that statement, then it's not exactly true. A List uses an array internally, so how could it be more efficient if it's a layer on top?
Avatar of ITsolutionWizard

ASKER

Yes. please close the question. so I can ask again. Nowday, I can't ask any more questions because this question block my way. Thanks
Please cancel this question. I can ask again.
The question says:

Basically Convert List<string> to String[]

...to which I gave a very succinct answer in the very first comment of this thread.
I believe Kaufmed has given a proper answer - my support
Hi anarki - Below codes work to me. The system.diagnostics shows me it work efficient. Thank for your helps

List<string> licenseDocList = new List<string>();
            foreach (string value in ViewLicenseDocumentList(76))
            {
                licenseDocList.Add(value);
                System.Diagnostics.Debug.WriteLine(value);
            }