Solved

csharp split string

Posted on 2012-03-29
2
303 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 40

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Syntax Error 2 65
What .NET URL re-routing tool did I use? 2 56
Gridview selected row 9 46
ASP.net File format issue in producing Excel file 3 37
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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