Do not know someone did not do to the day outsourcing, if done, then the vb.net should be very familiar with, when I just graduated from the time also did four months of outsourcing, that day is simply
Not people, even under the building to buy jewelry Aunt said, these children, only to see them work, have not seen them work, but a little good, there is a QA girl every afternoon 6
The point teaches US Cushaw language, now still is hooking up ...
OK, now let's look at the demand.
One: How to Tell If "a" is a numeric type.
①: In C # We may use TryParse to determine whether the current "a" is an integer.
1 Static voidMain (string[] args)2 {3 varA ="a";4 5 intR;6 7Console.WriteLine (int. TryParse (A, outR));8 9 Console.read ();Ten}
This tryparse, I think everyone is very familiar with, but the most annoying thing is, I just to know "a" is not an integer, but also to define an R variable, hate not annoying.
② using regular
Omnipotent regular, no it can not solve the problem, but for it, I have to write "expression", or a little trouble, do not like, I also want a simpler way.
1 varA ="a";2 3Console.WriteLine (Regex.IsMatch (A,"^\\d$"));4 5Console.read ();
③: If you know vb.net, then you will know that there is a IsNumeric method in VB.
1 SubMain ()2 3 DimA as String="a"4 5Console.WriteLine (IsNumeric(a))6 7 Console.read ()8 9 End Sub
When you see this method is not very good, below we continue to dig out which namespace is ok. Know the namespace, then we can not use C # take doctrine it?
Well, now has the TA stripped, but in the Microsoft.VisualBasic space, we also saw 7 seemingly very useful isxxx, too good ~ ~ ~
Below we add the following references.
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 using Microsoft.VisualBasic;7 usingSystem.Diagnostics;8 9 namespaceConsoleApplication1Ten { One class Program A { - Static voidMain (string[] args) - { the varA ="a"; - - Console.WriteLine (Information.isnumeric (a)); - + Console.read (); - } + } A}
These isxxx methods are very well-known, I do not need to code to explain, the following people are interested to try it yourself, these methods are very very useful,
not to do, only unexpected ~ such as IsDate method, if in C # to determine whether a string is time is more troublesome, or tryparse, or regular, the total
See, VS is a big platform, when C # is not good to implement, you can think about whether you can refer to the following methods in other languages, perhaps you have a big gain ~
Copyright NOTICE: This article for Bo Master http://www.zuiniusn.com original article, without Bo Master permission not reproduced.
Digging up a series of things that we don't use in C # (2)--isxxx series method