Solved

Drop Everything After Comma

Posted on 2008-09-29
7
432 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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 …
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…

816 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

9 Experts available now in Live!

Get 1:1 Help Now