It is great to see people writing about C#, but your article is missing crucial information.
Environment.FailFast() is for a very specific use-case and in general one should instead use Environment.Exit() to exit an application.
FailFast() is meant to be used when the process encounters a catastrophic error, such as one where external data could be destroyed. When the method is used, not only does it log an error with the OS, generate a memory dump, and try to send information to Microsoft, it also skips any active finally blocks and doesn't call any exit events. No one wants their application to panic, memory dump, and phone Microsoft every time it closes, so please use Exit() and not FailFast() to exit applications.
Also, it is great that you mentioned Environment.NewLine, but it is misleading to not explicitly point out that Environment.NewLine is a \n on Linux and \r\n on Windows as its purpose is to abstract over the OS differences of newline characters.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It is great to see people writing about C#, but your article is missing crucial information.
Environment.FailFast()
is for a very specific use-case and in general one should instead useEnvironment.Exit()
to exit an application.FailFast()
is meant to be used when the process encounters a catastrophic error, such as one where external data could be destroyed. When the method is used, not only does it log an error with the OS, generate a memory dump, and try to send information to Microsoft, it also skips any activefinally
blocks and doesn't call any exit events. No one wants their application to panic, memory dump, and phone Microsoft every time it closes, so please useExit()
and notFailFast()
to exit applications.Also, it is great that you mentioned
Environment.NewLine
, but it is misleading to not explicitly point out thatEnvironment.NewLine
is a\n
on Linux and\r\n
on Windows as its purpose is to abstract over the OS differences of newline characters.