basics programing some code problem

Posted by Srinivasulu.enugu under C# on 7/25/2011 | Points: 10 | Views : 970 | Status : [Member] | Replies : 1
Acually , whenever try to run this code , i got exception like Arrayoutofbound exception.

what is problem, can you explain this, it is mistake in my code. iam awaiting for your replay

class Program
{
// main program excution
static void Main(string[] args)
{
try
{

Console.WriteLine("sri,{0}!", args[0]);
Console.WriteLine("------hai second-------");
Console.ReadLine();
}
catch (IndexOutOfRangeException ex)
{
Console.WriteLine("please, check your range ",ex);
}
}

Srinivasulu Enugu


Responses

Posted by: Ndebata on: 7/25/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
Actually you are running your program from visual studio with no commandline argument and expecting a command line argument in your code. So it is throwing out of bound exception.

Try to run your exe from a visual studio command promt.
> [Pathofexe] SomeName 


It will show some name

Thanks,
Debata


Srinivasulu.enugu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response