C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

how to remove the numbers in end of the string


Posted Date: 10 Jan 2009      Posted By: yogaraj.p      Member Level: Silver     Points: 1   Responses: 6



hi friends,

how to remove the numbers in end of the string in c#. for example if the string is "keyword23" i want to remove "23" from "keyword23". but i dont want to remove the numbers in middle or start og the string.





Responses

Author: yogaraj.p    10 Jan 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 1

what will happen if the string will have three numeric values in end of the string


Author: yogaraj.p    10 Jan 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

no appukuttam, it wont work... because value.length-2 will remove only 2 values. if the string is keyword2345 then it will return keyword23 right. but i need only "keyword".


Author: Babu Kumarasamy    10 Jan 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi

use this

string rem = "45babu1234";
char[] c = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
string both = rem.Trim(c);
string end = rem.TrimEnd(c);
string start = rem.TrimStart(c);



Author: selvakumar.A    30 Jan 2009Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

Hi,

Try the following one

string name = "kkkk1234";
string result;

for (int i = 0; i <= name.Length - 1; i++)
{
if (char.IsDigit(Convert.ToChar(name.Substring(i, 1))) == false)
{
result += name.Substring(i, 1);
}
}
MessageBox.Show(result);



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Combox inside Datagrid view in C# windows application
Previous : Examples
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use