On Jun 17, 9:45*am, sony.m.2...@googlemail.com wrote:
Quote:
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
Sony,
Your method return an ArrayList, so you always have to return an
ArrayList.
You can use some like this:
Public Arraylist Test(int a)
{
ArrayList t1 = new ArrayList();
If(a<100)
{
t1.add(“100”);
}
Return t 1 ;
in your page use:
ArrayList retValue = Test(1000)
if ( retValue.Lenght == 0 )
{
// Do something
}
Sorry for my poor english, i am a brazilian programmer.
Regards