Please tell me whats wrong with this c# code..
public bool CloseCOMPort()
{
try
{
bool isClosed = false;
if (oSerialPortMisc != null && oSerialPortMisc.IsOpen)
{
oSerialPortMisc.Close();
isClosed=true;
}
else
{
isClosed = false;
}
return isClosed;
}
catch (Exception exp)
{
}
}
When I compile this code it gives error.. “not all code paths return a value”.
I dont know whts wrong here. PLease help..
Thanxxx…:)
To be more specific. Each fork in your code must either return an appropriate value or throw, if the method isn’t a void. In your case, the catch fork doesn’t do any of the above, and your code doesn’t compile.