Solved

Drop Everything After Comma

Posted on 2008-09-29
7
430 Views
Last Modified: 2008-09-29
I want this to drop everything after the comma, please see code sample below.
http://www.susan.com/racing/Pictures/Thumbs/thumbnail_susan.jpg, Some Text

Open in new window

0
Comment
Question by:net_susan
  • 3
  • 3
7 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 22600296
String newString = yourStringValue.Substring(0,yourString.IndexOf(','));
0
 
LVL 1

Accepted Solution

by:
PIER117 earned 500 total points
ID: 22600432

string MainString = "http://www.susan.com/racing/Pictures/Thumbs/thumbnail_susan.jpg, Some Text

"; 

string [] Split = MainString.Split(new Char [] {','}); 

string NewString = Convert.ToString(Split[0]); 

Open in new window

0
 
LVL 1

Author Comment

by:net_susan
ID: 22600467
Oh...I'm plugging it into (oListItem[("Picture")])

so would it be:

(Picture.Substring((oListItem[("Picture")]).Substring(0,Picture.IndexOf(','));
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 22

Expert Comment

by:p_davis
ID: 22600490
is that a question or a statement? did that work for you?
0
 
LVL 1

Author Comment

by:net_susan
ID: 22600690
No. I ended up with  'object' does not contain a definition for 'Substring'

I last tried:

(oListItem[("Picture")]).Substring(0,(oListItem[("Picture")]).IndexOf(','));
0
 
LVL 1

Author Comment

by:net_susan
ID: 22601420
I got it to work like this:

string MainString = Convert.ToString((oListItem2[("Picture")]));
string [] Split = MainString.Split(new Char [] {','});
string NewString = Convert.ToString(Split[0]);
0
 
LVL 22

Expert Comment

by:p_davis
ID: 22602153
umm, then just convert it to string with either the tostring() function that exists for every object in .net or the Convert.ToString() class method.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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…
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…

743 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

13 Experts available now in Live!

Get 1:1 Help Now