CKTIS / C#
System.Exception: praktische referentie
System.Exception: praktische referentie: Exception is de basis van beheerde fouten en bevat Message, StackTrace en optioneel InnerException.
Versie: .NET API; verified on .NET 10.0.14
Syntax
System.Exception /* select a documented member or constructor */Exception is de basis van beheerde fouten en bevat Message, StackTrace en optioneel InnerException.
Werp een specifieker type en voeg context toe zonder de oorspronkelijke inner exception te verliezen.
Stuur programmalogica niet via Message en gebruik throw in plaats van throw error om de stack te behouden.
StackTrace kan vóór het werpen null zijn en uitzonderingsserialisatie is geen stabiel protocol tussen systemen.
Het volledige programma gebruikt System.Exception werkelijk; de exact verwachte stdout is boom.
Voorbeelden
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var error = new Exception("boom");
Console.WriteLine(error.Message);
Resultaat
boom
Het volledige programma gebruikt `System.Exception` werkelijk; de exact verwachte stdout is `boom`.