S
sony.m.2007
Hi,
I’m new to ASP.NET
I have written a function with a return value.
If the arguments to the functions are invalid means I’m giving
exit(0)
Else means do some process and return a value.
When I compile the above code, it throws error and asked for a return
value in the IF part
Error 1 : not all code paths return a value
Example Code(just to describe)
Public Arraylist Test(int a)
{
ArrayList t1 = new ArrayList();
If(a>100)
{
System.Environment.Exit(0);
Return t1
}
else
{
t1.add(“100”);
Return t 1;
}
On page load I’m calling this function
protected void Page_Load(object sender, EventArgs e)
{
Int retValue=Test(1000)
}
My question is what’s the effect of return value after Exit function?
What return value did the calling function get from test function?
Kindly explain the concept
Thanks,
Sony
I’m new to ASP.NET
I have written a function with a return value.
If the arguments to the functions are invalid means I’m giving
exit(0)
Else means do some process and return a value.
When I compile the above code, it throws error and asked for a return
value in the IF part
Error 1 : not all code paths return a value
Example Code(just to describe)
Public Arraylist Test(int a)
{
ArrayList t1 = new ArrayList();
If(a>100)
{
System.Environment.Exit(0);
Return t1
}
else
{
t1.add(“100”);
Return t 1;
}
On page load I’m calling this function
protected void Page_Load(object sender, EventArgs e)
{
Int retValue=Test(1000)
}
My question is what’s the effect of return value after Exit function?
What return value did the calling function get from test function?
Kindly explain the concept
Thanks,
Sony