Solved

csharp split string

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

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