Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Drop Everything After Comma

Posted on 2008-09-29
7
Medium Priority
?
438 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 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