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
String newString = yourStringValue.Substring( 0,yourStri ng.IndexOf (','));
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh...I'm plugging it into (oListItem[("Picture")])
so would it be:
(Picture.Substring((oListI tem[("Pict ure")]).Su bstring(0, Picture.In dexOf(',') );
so would it be:
(Picture.Substring((oListI
is that a question or a statement? did that work for you?
ASKER
No. I ended up with 'object' does not contain a definition for 'Substring'
I last tried:
(oListItem[("Picture")]).S ubstring(0 ,(oListIte m[("Pictur e")]).Inde xOf(','));
I last tried:
(oListItem[("Picture")]).S
ASKER
I got it to work like this:
string MainString = Convert.ToString((oListIte m2[("Pictu re")]));
string [] Split = MainString.Split(new Char [] {','});
string NewString = Convert.ToString(Split[0]) ;
string MainString = Convert.ToString((oListIte
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.