473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

finding character in string

I want to find a particular character in a string, and then find the
length of the string after this point in the string, so that I can do a
rightpad on it if it is of a certain length (basically I want to pad a
monetary value if it is for example 12.5, so that it becomes 12.50).

I can think of a long winded way to do it by using a foreach loop to
find the '.', but is there a specific function in C# to find a character
in a string?
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #1
2 39263
hi Mike,

use the method String.IndexOf(char) to find the position
of a character.

Cheers
Marcello
-----Original Message-----
I want to find a particular character in a string, and then find thelength of the string after this point in the string, so that I can do arightpad on it if it is of a certain length (basically I want to pad amonetary value if it is for example 12.5, so that it becomes 12.50).
I can think of a long winded way to do it by using a foreach loop tofind the '.', but is there a specific function in C# to find a characterin a string?
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
.

Nov 13 '05 #2
Thanks for your help everybody. I've found a much easier way to do what
I was trying to do, simply formatting the string as a currency :

String.Format("{0:c}", string);
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: lawrence | last post by:
"Garp" <garp7@no7.blueyonder.co.uk> wrote in message news:<_vpuc.1424$j_3.13346038@news-text.cableinet.net>... > "lawrence" <lkrubner@geocities.com> wrote in message >...
10
by: M Bourgon | last post by:
I'm trying to figure out how to find the last whitespace character in a varchar string. To complicate things, it's not just spaces that I'm looking for, but certain ascii characters (otherwise,...
2
by: B Moor | last post by:
I have a database with 100,000's records, each with a unique reference, eg A123BNK456 I would like to generate a search facility whereby we can choose an exact match or partial match, where the...
4
by: David Warner | last post by:
Greetings! In looking into some C coding, I am looking for the C function that will search for multiple occurances of a same character in a string. For Instance: char str = "We the people...
14
by: Mr. B | last post by:
I want to return the name of the drawing file (DWG) from the end of a string. The string will be of varying lengths... as well as the drawing file name itself. I could do it the long way by...
2
by: ElkGroveR | last post by:
Hi there! I'm using PHP to create a simple, dynamic MySQL SELECT query. The user chooses a selection from a HTML Form SELECT element's many options and submits the form via a POST action. ...
14
by: prasadjoshi124 | last post by:
Hi All, I am writing a small tool which is supposed to fill the filesystem to a specified percent. For, that I need to read how much the file system is full in percent, like the output given...
2
by: Lucas Kruijswijk | last post by:
Hello, I am making some site, where I use UTF-8 encoding. From PHP I send mail. But, if possible I want to send the mail in ISO-8859-1 or KOI8-R (because still some mailers have problem with...
2
by: Maxington | last post by:
The problem I am left with is that I need to split a string into substrings and determine the character location of the 30th occurance of "\n" string. I have a string that has "\n" within it and I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.