CKTIS / C#
System.Exception: praktična referenca
System.Exception: praktična referenca: Exception je osnova upravljanih napak in vsebuje Message, StackTrace ter izbirni InnerException.
Različica: .NET API; verified on .NET 10.0.14
Sintaksa
System.Exception /* select a documented member or constructor */Exception je osnova upravljanih napak in vsebuje Message, StackTrace ter izbirni InnerException.
Sprožite natančnejši tip in dodajte kontekst brez izgube izvirne notranje izjeme.
Logike ne vodite z besedilom Message in uporabite throw namesto throw error, da ohranite sklad.
StackTrace je lahko pred sprožitvijo null, serializacija izjem pa ni stabilen protokol med sistemi.
Celoten program dejansko uporabi System.Exception; natančno pričakovani stdout je boom.
Primeri
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);
Rezultat
boom
Celoten program dejansko uporabi `System.Exception`; natančno pričakovani stdout je `boom`.