|
|
|
date: Tue, 08 Jul 2008 17:27:34 -0500,
group: microsoft.public.dotnet.framework.aspnet
back
Re: String\Delimiter
gh wrote:
> I have a string that is delimited with commas. Is there a function in
> C# that will break apart the string at each comma, so I can copy the
> value to a var? This is a .net v1.1.4 app.
The easiest way would be to use the Split method of the string class:
string[] subStrings = commaDelimitedString.Split(',');
Often a string is actually delimited with a comma and a space, in that
case you would want to split on the string ", " instead:
string[] subStrings = commaDelimitedString.Split(new string[]{", "},
StringSplitOptions.None);
If the space after the comma is optional, you would use two delimiter
strings:
string[] subStrings = commaDelimitedString.Split(new string[]{", ",
","}, StringSplitOptions.None);
--
Göran Andersson
_____
http://www.guffa.com
date: Wed, 09 Jul 2008 16:59:53 +0200
author: Göran Andersson
|
|