Example 1
try
{
}
catch(Exception ex)
{
throw;
} Example 2
try
{
}
catch(SQLException sqlex)
{
}
catch
{
throw;
} Example 3
try
{
}
catch(Exception ex)
{
throw ex;
} Can anyone tell me the difference between these 3 example?Thanks...
Example 1
try
{
}
catch(Exception ex)
{
throw;
} Example 2
try
{
}
catch(SQLException sqlex)
{
}
catch
{
throw;
} Example 3
try
{
}
catch(Exception ex)
{
throw ex;
} Can anyone tell me the difference between these 3 example?Thanks...
thats c# not vb but
try
{
//tries something
}
catch (sqlexception ex)
{
//returns if an sqlexception is caught
console.writeline(ex);
}
catch (OutOfMemoryException ex)
//return if an outofmemoryexception is caught
console.writeline(ex);
}
catch(exception ex)
{
//then you would catch anything that was missed by your drilled down error handling, this is a wide range of errors
console.writeline(ex);
} The throw statement is used to signal the occurrence of an anomalous situation (exception) during the program execution.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.