check number

Results 1 to 2 of 2

Thread: check number

  1. #1
    Join Date
    Dec 1969

    Default check number

    how do I check if a variable contains is a number or not, in C#<BR>example string strNum = "1000";<BR>string strNum1 = "1000a";<BR>strNum is correct & strNum1 is incorrect<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: check number

    Use a try/catch...I do not know C very well, so I&#039;m really not sure on the exact syntax...I would guess something like this:<BR><BR>String testVar1 = "1000a";<BR>try<BR>{<BR>**int testVar2 = Convert.Integer(testVar1);<BR>}<BR>catch (Exception er)<BR>{<BR>**String msg = er;<BR>}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts