Click here to Skip to main content
15,867,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want a code that deletes after specified word/number like...

if textbox contains ("123.4") i want to delete every word/number after "." with a code.
Posted
Updated 27-Apr-12 11:25am
v2

1 solution

This is very simple. You can use a combination of IndexOf and Replace or Loop through it yourself and copy only the valid characters to a new string. What part are you stuck on?

Edit:
You can try:
string x = "123.4".Split('.')[0];


Are you sure you don't want to round though? If so, try converting to number and using Math.Round, then convert back to string.
 
Share this answer
 
v3
Comments
kirubelye 27-Apr-12 17:39pm    
Please give me an example?

i have a ("12.2") and i want it to be ("12")i dont want it to display any thing after the dot and the dot itself
wizardzz 27-Apr-12 17:42pm    
if you know there will only be one dot (meaning you are trimming from numerical value), than you can check my updated answer.
wizardzz 27-Apr-12 17:50pm    
If it helped, can you mark my answer as Accepted please?

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