CKTIS / C#
System.InvalidOperationException: odniesienie praktyczne
System.InvalidOperationException: odniesienie praktyczne: InvalidOperationException oznacza operację niedozwoloną w bieżącym stanie obiektu.
Wersja: .NET API; verified on .NET 10.0.14
Składnia
System.InvalidOperationException /* select a documented member or constructor */InvalidOperationException oznacza operację niedozwoloną w bieżącym stanie obiektu.
Rzucaj, gdy argument może być poprawny, lecz kolejność wywołań lub stan nie.
Ogólne łapanie może ukryć błąd protokołu; napraw stan lub kolejność.
Częste źródła to pusta kolekcja dla Single/Pop i ponowne użycie zakończonego obiektu.
Kompletny program rzeczywiście używa System.InvalidOperationException; oczekiwany stdout to dokładnie bad state.
Przykłady
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 InvalidOperationException("bad state"); } catch (InvalidOperationException error) { Console.WriteLine(error.Message); }
Wynik
bad state
Kompletny program rzeczywiście używa `System.InvalidOperationException`; oczekiwany stdout to dokładnie `bad state`.