|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Splitting a string array to seperate variablesQuick C# question:
I have comma delimited values in a string array that I want to pass to seperate variables. Any tips on splitting the array? Thanks in advance! JM *** Sent via Developersdex http://www.developersdex.com *** First thing that comes to mind is the string Split method:
string csv = "1,2,3,4"; string [] numbers = csv.Split(",".ToCharArray()); Here is the MSDN docs and samples to do this: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemstringclasssplittopic.asp Alex Show quoteHide quote "JeffM" <Je***@devdex.com> wrote in message news:O1TDDETOFHA.2704@TK2MSFTNGP15.phx.gbl... > Quick C# question: > I have comma delimited values in a string array that I want to pass to > seperate variables. Any tips on splitting the array? > > Thanks in advance! > > JM > > > > *** Sent via Developersdex http://www.developersdex.com *** If you also want to split quoted fields and/or ignore multiple delim in a
row, check out: http://spaces.msn.com/members/staceyw/Blog/cns!1pnsZpX0fPvDxLKC6rAAhLsQ!352.entry Show quoteHide quote "JeffM" <Je***@devdex.com> wrote in message news:O1TDDETOFHA.2704@TK2MSFTNGP15.phx.gbl... > Quick C# question: > I have comma delimited values in a string array that I want to pass to > seperate variables. Any tips on splitting the array? > > Thanks in advance! > > JM > > > > *** Sent via Developersdex http://www.developersdex.com *** Wow, that's a pretty cool script.
Although I am generating test files out of Excel, so spacing and formatting should be OK, this is very nice to allow commas in the input string itself. Thanks much :-) JM *** Sent via Developersdex http://www.developersdex.com ***
Other interesting topics
include build time in exe file
exchanging data between a win32 application (service) and a c# application (service) C# Reflection - Nasty bug?? xpath in c# Control-click Start and exit applcation(s) using Windows Services deployment of dot net desktop project with crystal reports Retrieving HTTP Response Code Form Post - Session Values message box fonts are invisible |
|||||||||||||||||||||||