Solved

Search string - "," Vs ",,"

Posted on 2009-04-07
2
157 Views
Last Modified: 2012-05-06
I have a sting - which sometimes will contain values seperated by a single comma (,) and other times values seperated by double commas (,,)

I know how to do this - Contains(","))
but if seems like it is obviously also catchinginstances where ,, exist

Question is - how can I differentiate between the two instances?
0
Comment
Question by:tbaseflug
  • 2
2 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
Comment Utility
something like this:




if (myStr.Contains(",,"))

{

    // do some things for strings separated by double comma

} else

{

    // do some things for strings separated by single comma

}

Open in new window

0
 
LVL 39

Expert Comment

by:abel
Comment Utility
Or, if your situation contains situations where you have strings where values are separated by one or two comma's, but also where other values exist.

The basic thought is: start out with testing for the most specific situation, then go to the less specific situation.

if (myStr.Contains(",,"))

{

    // do some things for strings separated by double comma

} elseif (myStr.Contains(","))

{

    // do some things for strings separated by single comma

} else

{

    // so some things for strings with no commas

}

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

10 Experts available now in Live!

Get 1:1 Help Now