Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to replace particular letter in given string
Posted
Comments
Fredrik Bornander 30-Jun-11 6:58am    
.Replace ?

YourText = YourText.Replace("c"c,"x"c)

Update: Added a "c" to cast the string to character.
 
Share this answer
 
v2
Comments
Tarun.K.S 30-Jun-11 7:04am    
Updated the answer by adding a "c". Gets my 5.
Prerak Patel 30-Jun-11 7:05am    
It doesn't matter in VB.net
Thanks anyways.
Tarun.K.S 30-Jun-11 7:10am    
Actually it does.
Prerak Patel 30-Jun-11 7:11am    
Actually Replace has two overloaded forms: Replace(Char, Char) and Replace(String, String)
http://msdn.microsoft.com/en-us/library/system.string.replace.aspx
Tarun.K.S 30-Jun-11 7:27am    
Ohkay boss!
Did you even bother to check the different properties and methods of string? You can use the string.Replace method to replace both characters and strings.

Dim s As String = "How are you doing?"
Dim newString As String = s.Replace("H"c,"h"c)

Result : how are you doing?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900