Solved

Drop Everything After Comma

Posted on 2008-09-29
7
435 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 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WPF user control poped up from a window 1 47
parse string in c# 5 40
How does this modal work? 3 33
SQL State HYT00. Timeout expired proplem 8 42
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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