CSharp.targets erros
After I read the article,I recommeneded before, on code project. I finally solved the problem for CSharp.targets errors. Because I have not installed CF .net powertoys. Now, everythings are alright!
Windows Mobile without Visual Studio
http://www.codeproject.com/KB/mobile/WiMoSansVS.aspx
That is a good article to teach yourself for the mobile application in SharpDevelopment
WPF Programmer is easy to Android Programming
I am learning the application programming on Android OS. I found that is easier to catch up because I am a WPF Programmer. Both of them are using xml to draw UI. That is not a strange thing for myself.
Regular Expression Validation
I like to use regular expression validation. That is simple.
You only need to use:
Code
using System.Text.RegularExpressions |
For the numeric value validation:
Code
Regex regex = new Regex(@"^[0-9]*$"); | |
if (!regex.IsMatch(textBox1.Text)) | |
{ | |
MessageBox.Show("Invalid value, integer only!"); | |
} |
Use tryparse if that is possible or have a validation
I faced a number of error for parsing a string into int. In most of cases, there is a validation missing.
Code
If (IsNumeric(str)) | |
{ | |
int i =0; | |
Int32.TryParse(str,out i); | |
} |
You can use regex inside IsNumber or use foreach loop to check whether each character is numberic.
BUT NEVER NEVER DO LIKE THIS:
Code
try | |
{ | |
int i= Int32.Parse(i); | |
} | |
catch(FormatException) | |
{ | |
// Error Hanlding | |
} |
Try-catch is an expensive operation!!!!!!!!
Secondly, I like to use TryParse even in the case, the progam can tolrate invalid value. TryParse can allow the logic to continue execution. I hate some things like stack track on the screen.
