Limit Input to Two Decimal Places in C#

Sometimes you need to restrict the input to two decimal places in C#. The following function returns true if the input is valid, otherwise it returns false.

You will need to listen to a Key_Down event handler for your TextBox and put the following code in it. Setting e.handled to true prevents the current character to be input in the TextBox.

ashishumar468@gmail.com'

Ashish Kumar

I am pursuing my Btech from MIT, Pune and I like to develop and blog about Windows Phone apps.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close