CKTIS / C#
System.ArgumentException: praktična referenca
System.ArgumentException: praktična referenca: ArgumentException označuje argument, ki ni null in krši pogodbo, ter lahko ohrani svoj ParamName.
Različica: .NET API; verified on .NET 10.0.14
Sintaksa
System.ArgumentException /* select a documented member or constructor */ArgumentException označuje argument, ki ni null in krši pogodbo, ter lahko ohrani svoj ParamName.
Sprožite jo na javni meji po zaznavi neveljavne vrednosti argumenta.
Logike ne vodite po besedilu Message, ker je lokalizirano; raje izberite natančnejši podtip.
ParamName je lahko null; zgolj prestrezanje izjeme ne popravi neveljavne vrednosti.
Celoten program dejansko uporabi System.ArgumentException; natančno pričakovani stdout je value.
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;
try { throw new ArgumentException("invalid", "value"); } catch (ArgumentException error) { Console.WriteLine(error.ParamName); }
Rezultat
value
Celoten program dejansko uporabi `System.ArgumentException`; natančno pričakovani stdout je `value`.