Solved

csharp split string

Posted on 2012-03-29
2
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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