ITsolutionWizard
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(',');
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(',');
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:
Just replace Environment.NewLine with a delimiter you want...
You can do like here:
string combindedString = string.Join( Environment.NewLine, licenseDocList.ToArray() );// print every element from new line
Just replace Environment.NewLine with a delimiter you want...
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 );
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@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?
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
ASKER
Please cancel this question. I can ask again.
The question says:
...to which I gave a very succinct answer in the very first comment of this thread.
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
ASKER
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.W riteLine(v alue);
}
List<string> licenseDocList = new List<string>();
foreach (string value in ViewLicenseDocumentList(76
{
licenseDocList.Add(value);
System.Diagnostics.Debug.W
}