Solved

csharp split string

Posted on 2012-03-29
2
298 Views
Last Modified: 2012-03-29
need to get this right:

string getVal = ddlSNRN.SelectedValue.ToString(); //1043...N180HM
            string[] partsOfGetVal;
            partsOfGetVal = getVal.Split("...".ToCharArray());
            string sn = partsOfGetVal[0]; //1043
            string no = partsOfGetVal[1]; //

no seems to be returning nothing
0
Comment
Question by:fwstealer
2 Comments
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 37783376
You should remove the empty entries as follows:
string getVal = ddlSNRN.SelectedValue.ToString(); //1043...N180HM
string[] partsOfGetVal;
partsOfGetVal = getVal.Split("...".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
string sn = partsOfGetVal[0]; //1043
string no = partsOfGetVal[1]; //

Open in new window

0
 
LVL 39

Expert Comment

by:Kyle Abrahams
ID: 37783422
getVal.Split("...".ToCharArray());


.ToChar Array is seperating out the ... to individual "."

Removing the empty entries will work.  

The Value can be found in [3] using the current code.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now