Create a custom exception and throw.
You will need to create your own CustomException
that contains a message and a property of type DateTime
, representing the time the exception was thrown (throw new...
).
In your main program, create a function ThrowError()
that simply throws a CustomException
with the appropriate information.
Call this function from the Main
method, ensuring it is properly wrapped in a try/catch block, and display the date and message of the exception in the console.