Re: Splitting a String
- From: Ludwig <none@xxxxxxxx>
- Date: Sat, 20 May 2006 13:37:27 +0200
On Fri, 19 May 2006 20:33:29 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Materialised,
Why not just do this?
public static int[] SplitBarCode(string barcode)
{
// The return value.
int[] retVal = new int[4];
// Split the string.
retVal[0] = Int32.Parse(barcode.Substring(0, 2));
retVal[1] = Int32.Parse(barcode.Substring(2, 5));
retVal[2] = Int32.Parse(barcode.Substring(7, 5));
retVal[3] = Int32.Parse(barcode.Substring(12, 1));
// Return the value.
return retVal;
}
Of course, you might want to put a little more error handling into this,
but this should do it.
Hope this helps.
Use regular expression (RegEx class) and its Split method!.
--
Ludwig Stuyck
http://www.coders-lab.be
.
- Follow-Ups:
- Re: Splitting a String
- From: Marcus Andrén
- Re: Splitting a String
- From: Mark Rae
- Re: Splitting a String
- References:
- Splitting a String
- From: Materialised
- Re: Splitting a String
- From: Nicholas Paldino [.NET/C# MVP]
- Splitting a String
- Prev by Date: Re: Suggestions Please !!!
- Next by Date: Re: Splitting a String
- Previous by thread: Re: Splitting a String
- Next by thread: Re: Splitting a String
- Index(es):
Relevant Pages
|