Share via


Command line input parameter converting string to integer in C#

Question

Wednesday, August 28, 2013 8:14 PM

Hi Folks,

I am a rookie at this and need some guidance.  I do not get the result I want with the below code. I am trying to setup an input parameter but not sure if I am doing it correctly.   Is the below all I need to do to convert an  input parameter to an integer?  I am expecting to user to input a value from 1 - 1000000.

Thanks!

 

static void DeleteCAL(string[] args)
        {

            int a;
             a = int.Parse(args[0]);
  .
  .
  .
          5000 > a then delete

All replies (2)

Wednesday, August 28, 2013 8:19 PM âś…Answered | 1 vote

yes that will work

int a = int.Parse(args[0]a);// orint b = Convert.ToInt32(args[0]);// orint c = (int)args[0];

Wednesday, August 28, 2013 9:02 PM

Great, I don't know what I was doing wrong but I took the first part of the code you gave me and it worked. Thanks!!