Edit: cyberkiwi understood the question better than me, but I will let him seem like a bad reading example;)
You can always define your own exception class:
[Serializable()] public class OwnException : System.Exception { public readonly MaybeDateTime; ... public OwnException (string message, System.Exception inner) : base(message, inner) { maybe = null; } public OwnException (string message, System.Exception inner, DateTime maybe) : base(message, inner) { MaybeDateTime = maybe; } }
and drop it (date and time assignment).
You will need to transfer the datetime DateTime declaration outside of the try-catch block and in your example SLaks is right: it does not make sense. datetime can only contain something meaningful if return-Statement throws a catch exception. In other cases, there may be useful applications.
Edit: The same thing can be done with the string, but in order to restore this as an exception, if returning the current time solves the situation in a good way, it will be somewhat idiotic. Did not read correctly as stated above.
source share