c# - Console Window doesn't appear after re-opening project in Visual Studio -


i wrote program in c# convert binary string other digital number systems , int , worked fine , saved , closed it. when reopen it, exception:

$exception {"cannot read keys when either application not have console or when console input has been redirected file. try console.read."} system.invalidoperationexception

this because have console.readkey(); @ end of program. when remove this, console window doesn't appear @ , process ends though program asks user input. here program reference:

> using system; using system.collections.generic; using system.linq; > using system.text; using system.threading.tasks; >  > namespace test { >     class program >     { >         static void main(string[] args) >         { >             int arr_length = 16; >             string c_array = "\0"; >             int[] array = new int[arr_length]; >             console.writeline("input 2 byte string:"); >             (int = 0; < arr_length; i++) >             { >                 array[i] += convert.toint32(console.readline()); >                 c_array += array[i]; >             } >             int sum = 0; >             (int = 0; < arr_length; i++) >             { >                 sum += array[arr_length - 1 - i] * convert.toint32(math.pow(2, i)); //conversion int     >             } >             console.writeline("the decimal representation is: " + sum); >             console.writeline("the hex representation is:" + sum.tostring("x")); >             bool valid_bcd = true; >             int bcd_0 = 0, bcd_1 = 0, bcd_2 = 0, bcd_3 = 0; >             (int = 0; < 4; i++) >             { >                 bcd_0 += array[arr_length - 1 - i] * convert.toint32(math.pow(2, i)); >                 if (bcd_0 > 9) valid_bcd = false; >             } >             (int = 4; < 8; i++) >             { >                 bcd_1 += array[arr_length - 1 - i] * convert.toint32(math.pow(2, (i - 4))); >                 if (bcd_1 > 9) valid_bcd = false; >             } >             (int = 8; < 12; i++) >             { >                 bcd_2 += array[arr_length - 1 - i] * convert.toint32(math.pow(2, (i - 8))); >                 if (bcd_2 > 9) valid_bcd = false; >             } >             (int = 12; < 16; i++) >             { >                 bcd_3 += array[arr_length - 1 - i] * convert.toint32(math.pow(2, (i - 12))); >                 if (bcd_3 > 9) valid_bcd = false; >             } >             if (valid_bcd) >             { >                 console.writeline("the bcd representation is: " + "{0}{1}{2}{3}", bcd_3, bcd_2, bcd_1, bcd_0); >             } >             else console.writeline("error!! cannot convert bcd"); >             bool valid_ascii = true; >             char ascii_0 = 'a', ascii_1 = 'a'; >             int sum_ascii = 0; >             (int = 0; < 8; i++) >             { >                 sum_ascii += array[arr_length - 1 - i] * convert.toint32(math.pow(2, i)); >                 if (sum_ascii < 127) ascii_0 = (char)sum_ascii; >                 else valid_ascii = false; >             } >             sum_ascii = 0; >             (int = 8; < 16; i++) >             { >                 sum_ascii += array[arr_length - 1 - i] * convert.toint32(math.pow(2, (i - 8))); >                 if (sum_ascii < 127) ascii_1 = (char)sum_ascii; >                 else valid_ascii = false; >             } >             if (valid_ascii) >             { >                 console.writeline("the ascii representation is: " + "{0}{1}", ascii_1, ascii_0); >             } >             else console.writeline("error!! cannot convert ascii"); >             console.readkey(); >         } >     } } 


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -