Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- /* a helper class, Tester, begun in Lesson 5 of intro C# console
- programming series found at the following URL:
- http://williammillerservices.com/windows-c-console-programming/
- note: to use, you would reference the file containing this code
- from your primary program file. If you have the following program...
- GitHub gist -> https://gist.github.com/kyrathasoft/35357f7fee1c427693323286111e5e43
- Pastebin.com -> https://pastebin.com/edit/K6D01kgv
- using System;
- using TestInput;
- namespace MyNS{
- class MyCls{
- public static void Main(){
- string sNum = "4";
- if(Tester.IsInteger(sNum)){
- Console.WriteLine("Yes, we can parse {0} to an int.", sNum);
- }
- }
- }
- }
- ...and if above program named test.cs and below is tester.cs and in
- same directory, then we'd compile like so:
- csc /out:test.exe test.cs tester.cs
- Running resulting test.exe would produce: Yes, we can parse 4 to an int.
- Or, we could make tester.cs code into DLL via:
- csc /t:library tester.cs
- ...and then compile like so:
- csc /r:tester.dll test.cs
- */
- namespace TestInput
- {
- public class Tester
- {
- public static bool IsInteger(string p)
- {
- bool result = false;
- int i;
- if (int.TryParse(p, out i))
- {
- result = true;
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement