473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

.Split cuts off a number

In my array i have 10|5.98

string[] mySplit = myArray.Split('|');
string DeliveryAddress = mySplit[0];
string ShippingID = mySplit[1];

my problem is ShippingID contains 5.9 not 5.98

can anyone tell me where my last number has gone, or how i get around this
problem?

Thanks in advance
Mike

Nov 16 '05 #1
2 1606
mike <sp******@hotmail.com> wrote:
In my array i have 10|5.98

string[] mySplit = myArray.Split('|');
string DeliveryAddress = mySplit[0];
string ShippingID = mySplit[1];

my problem is ShippingID contains 5.9 not 5.98

can anyone tell me where my last number has gone, or how i get around this
problem?


I suspect your problem doesn't lie where you think it does.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Here's a short but complete example which *doesn't* show the problem -
it shows Split working perfectly well:

using System;

class Test
{
static void Main()
{
string myArray = "10|5.98";
string[] mySplit = myArray.Split('|');
string DeliveryAddress = mySplit[0];
string ShippingID = mySplit[1];
Console.WriteLine(DeliveryAddress);
Console.WriteLine(ShippingID);
}
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Hi Mike,

Split has always worked fine with me, are you sure that myArray ( a string
variable right? ) contain the value you think?
I will try to guess here, but it seems that you build this value somewhere
from two numeric values, maybe the numeric value is 5.98 but it gets rounded
to 5.9 somehow?

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"mike" <sp******@hotmail.com> wrote in message
news:vj*****************@fe1.news.blueyonder.co.uk ...
In my array i have 10|5.98

string[] mySplit = myArray.Split('|');
string DeliveryAddress = mySplit[0];
string ShippingID = mySplit[1];

my problem is ShippingID contains 5.9 not 5.98

can anyone tell me where my last number has gone, or how i get around this
problem?

Thanks in advance
Mike


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: nieuws | last post by:
Hi, I was trying to do the following. It's my first php "project", so it's quiet logic that i have some problems. Perhaps the php community might help. It's about this : I have a txt file...
3
by: rxl124 | last post by:
Hi, room Beginner of learning perl here!! I have question to all, I have below file name datebook.master which contains only 2 lines Mike wolf:12/3/44:144 park ave, paramus: 44000 Sarah kim:...
9
by: martin | last post by:
Hi, a very newbie question. How do I split the adress and number to 2 variables? ex. "Kingsroad 347" = variabel1 = "Kingsroad" variabel2 = "347" Ill guess i have to search the string from...
12
by: Corey Burnett | last post by:
I have a client that has a split database (front-end/back-end). They are also using Access security - MDW file. The front end MDE file, the back end MDB file, and the MDW file are all located on...
1
by: Mike P | last post by:
I am using Split to split get a number of items from a multi line text box. But I need to be able to get the number of elements within the text box (e.g. if the text box has 2,4,8 in it, I want to...
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
12
by: Pascal | last post by:
hello and soory for my english here is the query :"how to split a string in a random way" I try my first shot in vb 2005 express and would like to split a number in several pieces in a random way...
1
by: Seth Williams | last post by:
I've got a strange problem - - I've got an input form (members), which has standard data, name, address, phone, etc I've changed the table now, so that the phone number accepts a varchar(25) - I...
2
by: ogo796 | last post by:
Hi guys am having a problem with a split(),i retrieve line from the text file and i wanna split that line.i manage to split two words but splitting the string enclosed on brackets it seems to be a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.