Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
ASP.NET C# Substring/Trim, Etc.
Old 08-18-2011, 04:04 PM ASP.NET C# Substring/Trim, Etc.
mb2000inc's Avatar
Extreme Talker

Posts: 150
Name: Mark
Location: Ohio
Trades: 0
So, I'm pulling a field from a table in a database.
This field has about 4 or 5 tag words in it - each separated by a comma (",").
The first tag word in each record is all I need (for this particular function).

So, the question is, how do I extract the first string of characters up to (not including) the first comma?
__________________
Need a vacation.

Last edited by mb2000inc; 08-18-2011 at 04:17 PM..
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
 
Register now for full access!
Old 08-18-2011, 04:45 PM Re: ASP.NET C# Substring/Trim, Etc.
mb2000inc's Avatar
Extreme Talker

Posts: 150
Name: Mark
Location: Ohio
Trades: 0
heh, never mind. I got it.

Code:
Substring(0, dbReader["Tags"].ToString().Trim().IndexOf(','));
substring using index of.... I'm a dork.

thanks anyway
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 08-19-2011, 11:00 AM Re: ASP.NET C# Substring/Trim, Etc.
Extreme Talker

Posts: 246
Trades: 0
you could probably also do the following:

Code:
dbReader["Tags"].ToString().Trim().Split(",")[0]
Not really sure if it works, but I think it would.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
Reply With Quote
View Public Profile
 
Old 03-07-2012, 11:08 AM Re: ASP.NET C# Substring/Trim, Etc.
Novice Talker

Posts: 10
Trades: 0
When I'm doing something like that I like to split, as stbuchok said
BradCliff is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ASP.NET C# Substring/Trim, Etc.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.67311 seconds with 12 queries