Mercurial > repos > IBBoard
annotate CustomMath/NumberParser.cs @ 100:fa8378a30ed2
* Add some Stream handling utilities
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 06 Mar 2011 14:51:05 +0000 |
parents | dfb7cb94c169 |
children |
rev | line source |
---|---|
17
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (NumberParser.cs) is a part of the IBBoard utils library and is copyright 2009 IBBoard. |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license. Please see COPYING.LGPL for more information and the full license. |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using System; |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 namespace IBBoard |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 { |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 public class NumberParser |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 { |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 public static int ParseAsInt(string numberString, int defaultValue) |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 { |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 int parsedValue = defaultValue; |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 int.TryParse(numberString, out parsedValue); |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 return parsedValue; |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 } |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 } |
dfb7cb94c169
Add number parser class with static method for ints
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 } |