The usual way of handling an error condition in .NET is to throw an exception:
public static double function(int a) {
if (a == 1) {
throw new ArgumentException("The value 1 is not accepted.");
}
return (double)a;
}
The exception would be caught by the code calling the method, or somewhere down the line. It's up to the calling code to handle it at an appropriate level.
It's quite usual for methods to sanitise the input in this manner, so that any faulty values are caught early instead of causing an error later in the code where it is much harder to track down.