docs
docs copied to clipboard
Code is incorrect
Though the example Console app is conceptually correct, the "return;" statement needs to return something convertible to a StreamWriter or "null;"
Incorrect code:
static StreamWriter OpenStream(string path) { if (path is null) { Console.WriteLine("You did not supply a file path."); return; }
Possible correct code:
static StreamWriter OpenStream(string path) { if(path is null) { Console.WriteLine("You did not supply a file path (at least, not a correct one!)."); return null; }
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 29117909-70a2-d388-2299-c98545324baa
- Version Independent ID: ed6298be-6655-9102-cf34-fcc3ca3a1147
- Content: Handling I/O errors in .NET
- Content Source: docs/standard/io/handling-io-errors.md
- Product: dotnet
- GitHub Login: @rpetrusha
- Microsoft Alias: ronpet