Link to home
Start Free TrialLog in
Avatar of net_susan
net_susan

asked on

Drop Everything After Comma

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

Avatar of p_davis
p_davis

String newString = yourStringValue.Substring(0,yourString.IndexOf(','));
ASKER CERTIFIED SOLUTION
Avatar of PIER117
PIER117

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of net_susan

ASKER

Oh...I'm plugging it into (oListItem[("Picture")])

so would it be:

(Picture.Substring((oListItem[("Picture")]).Substring(0,Picture.IndexOf(','));
is that a question or a statement? did that work for you?
No. I ended up with  'object' does not contain a definition for 'Substring'

I last tried:

(oListItem[("Picture")]).Substring(0,(oListItem[("Picture")]).IndexOf(','));
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]);
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.