Trim a comma off end of string??? 
Author Message
 Trim a comma off end of string???

cn,

    Simple! =)

// Trim the last character from the string.
strMyString = strMyString.Substring(0, strMyString.Length - 1);

    Hope this helps.

--
               - Nicholas Paldino [.NET/C# MVP]


Quote:
> I have just created an array string and want to be able
> to remove the comma at the end of the string. How do I do
> this?

> strMyString = "Member1, Member2, Member3,"



Sat, 30 Apr 2005 04:29:25 GMT  
 Trim a comma off end of string???
Use String.LastIndexOf and String.Remove methods -
       string strMyString = "Member1,Member2,Member3,";
       int index = strMyString.LastIndexOf(",");
       string strNewString = strMyString.Remove(index, 1);


Quote:
> I have just created an array string and want to be able
> to remove the comma at the end of the string. How do I do
> this?

> strMyString = "Member1, Member2, Member3,"



Sat, 30 Apr 2005 04:50:01 GMT  
 Trim a comma off end of string???
I have just created an array string and want to be able
to remove the comma at the end of the string. How do I do
this?

strMyString = "Member1, Member2, Member3,"



Sat, 30 Apr 2005 04:20:38 GMT  
 Trim a comma off end of string???
Alternately, you can do this:

strMyString = strMyString.TrimEnd(',');

Chris R.


Quote:
> I have just created an array string and want to be able
> to remove the comma at the end of the string. How do I do
> this?

> strMyString = "Member1, Member2, Member3,"



Sat, 30 Apr 2005 04:51:07 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Need help to trim spaces off a string

2. how do i place an end of string char at the end of a string

3. off the end of main

4. Help to trim spaces of a string

5. trim the string

6. String.Trim() behavior

7. String.Trim is this correct functionality

8. String.Trim();

9. trimming a string

10. How to trim a string in a _variant_t

11. How to trim a String?

12. Right trim string function in C

 

 
Powered by phpBB® Forum Software