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

LVL 1
net_susanAsked:
Who is Participating?
 
PIER117Connect With a Mentor Commented:

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
 
p_davisCommented:
String newString = yourStringValue.Substring(0,yourString.IndexOf(','));
0
 
net_susanAuthor Commented:
Oh...I'm plugging it into (oListItem[("Picture")])

so would it be:

(Picture.Substring((oListItem[("Picture")]).Substring(0,Picture.IndexOf(','));
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
p_davisCommented:
is that a question or a statement? did that work for you?
0
 
net_susanAuthor Commented:
No. I ended up with  'object' does not contain a definition for 'Substring'

I last tried:

(oListItem[("Picture")]).Substring(0,(oListItem[("Picture")]).IndexOf(','));
0
 
net_susanAuthor Commented:
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
 
p_davisCommented:
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
All Courses

From novice to tech pro — start learning today.