InvalidTimeZoneException 생성자

정의

InvalidTimeZoneException 클래스의 새 인스턴스를 초기화합니다.

오버로드

InvalidTimeZoneException()

시스템 제공 메시지를 사용하여 InvalidTimeZoneException 클래스의 새 인스턴스를 초기화합니다.

InvalidTimeZoneException(String)

지정된 메시지 문자열을 사용하여 InvalidTimeZoneException 클래스의 새 인스턴스를 초기화합니다.

InvalidTimeZoneException(SerializationInfo, StreamingContext)
사용되지 않음.

serialize된 데이터로부터 InvalidTimeZoneException 클래스의 새 인스턴스를 초기화합니다.

InvalidTimeZoneException(String, Exception)

지정된 오류 메시지와 해당 예외의 원인인 내부 예외에 대한 참조를 사용하여 InvalidTimeZoneException 클래스의 새 인스턴스를 초기화합니다.

InvalidTimeZoneException()

Source:
InvalidTimeZoneException.cs
Source:
InvalidTimeZoneException.cs
Source:
InvalidTimeZoneException.cs

시스템 제공 메시지를 사용하여 InvalidTimeZoneException 클래스의 새 인스턴스를 초기화합니다.

public:
 InvalidTimeZoneException();
public InvalidTimeZoneException ();
Public Sub New ()

설명

클래스의 매개 변수가 없는 생성자입니다 InvalidTimeZoneException . 새 instance 속성을 "'System.InvalidTimeZoneException' 형식의 예외가 throw되었습니다."와 같이 오류를 설명하는 시스템 제공 메시지로 초기화 Message 합니다. 이 메시지는 현재 시스템 문화권에 대해 지역화됩니다.

적용 대상

InvalidTimeZoneException(String)

Source:
InvalidTimeZoneException.cs
Source:
InvalidTimeZoneException.cs
Source:
InvalidTimeZoneException.cs

지정된 메시지 문자열을 사용하여 InvalidTimeZoneException 클래스의 새 인스턴스를 초기화합니다.

public:
 InvalidTimeZoneException(System::String ^ message);
public InvalidTimeZoneException (string message);
public InvalidTimeZoneException (string? message);
new InvalidTimeZoneException : string -> InvalidTimeZoneException
Public Sub New (message As String)

매개 변수

message
String

예외를 설명하는 문자열입니다.

설명

매개 변수로 message 제공된 문자열은 속성에 Message 할당됩니다. 현재 문화권에 대해 지역화해야 합니다.

적용 대상

InvalidTimeZoneException(SerializationInfo, StreamingContext)

Source:
InvalidTimeZoneException.cs
Source:
InvalidTimeZoneException.cs
Source:
InvalidTimeZoneException.cs

주의

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

serialize된 데이터로부터 InvalidTimeZoneException 클래스의 새 인스턴스를 초기화합니다.

protected:
 InvalidTimeZoneException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected InvalidTimeZoneException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected InvalidTimeZoneException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new InvalidTimeZoneException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> InvalidTimeZoneException
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new InvalidTimeZoneException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> InvalidTimeZoneException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

매개 변수

info
SerializationInfo

serialize된 데이터가 들어 있는 개체입니다.

context
StreamingContext

serialize된 데이터가 들어 있는 스트림입니다.

특성

예외

info 매개 변수가 null인 경우

또는

context 매개 변수가 null인 경우

설명

이 생성자는 개체를 인스턴스화 InvalidTimeZoneException 하기 위해 코드에서 직접 호출되지 않습니다. 대신 스트림에서 개체를 IFormatter 역직렬화 InvalidTimeZoneException 할 때 개체의 Deserialize 메서드에 의해 호출됩니다.

적용 대상

InvalidTimeZoneException(String, Exception)

Source:
InvalidTimeZoneException.cs
Source:
InvalidTimeZoneException.cs
Source:
InvalidTimeZoneException.cs

지정된 오류 메시지와 해당 예외의 원인인 내부 예외에 대한 참조를 사용하여 InvalidTimeZoneException 클래스의 새 인스턴스를 초기화합니다.

public:
 InvalidTimeZoneException(System::String ^ message, Exception ^ innerException);
public InvalidTimeZoneException (string message, Exception innerException);
public InvalidTimeZoneException (string? message, Exception? innerException);
new InvalidTimeZoneException : string * Exception -> InvalidTimeZoneException
Public Sub New (message As String, innerException As Exception)

매개 변수

message
String

예외를 설명하는 문자열입니다.

innerException
Exception

현재 예외의 원인인 예외입니다.

예제

다음 코드는 중앙 표준 시간대를 TimeZoneInfo 나타내는 개체를 검색하려고 합니다. InvalidTimeZoneException 메서드 호출에서 RetrieveTimeZone 가 발생하면 예외 처리기는 호출자에게 반환되는 새 InvalidTimeZoneException 개체에서 예외를 래핑합니다. 호출자의 예외 처리기는 외부 및 내부 예외에 대한 정보를 표시합니다.

private void HandleInnerException()
{   
   string timeZoneName = "Any Standard Time";
   TimeZoneInfo tz;
   try
   {
      tz = RetrieveTimeZone(timeZoneName);
      Console.WriteLine("The time zone display name is {0}.", tz.DisplayName);
   }
   catch (TimeZoneNotFoundException e)
   {
      Console.WriteLine("{0} thrown by application", e.GetType().Name);
      Console.WriteLine("   Message: {0}", e.Message);
      if (e.InnerException != null)
      {
         Console.WriteLine("   Inner Exception Information:");
         Exception innerEx = e.InnerException;
         while (innerEx != null)
         {
            Console.WriteLine("      {0}: {1}", innerEx.GetType().Name, innerEx.Message);
            innerEx = innerEx.InnerException;
         }
      }            
   }   
}

private TimeZoneInfo RetrieveTimeZone(string tzName)
{
   try
   {
      return TimeZoneInfo.FindSystemTimeZoneById(tzName);
   }   
   catch (TimeZoneNotFoundException ex1)
   {
      throw new TimeZoneNotFoundException( 
            String.Format("The time zone '{0}' cannot be found.", tzName), 
            ex1);
   }          
   catch (InvalidTimeZoneException ex2)
   {
      throw new InvalidTimeZoneException( 
            String.Format("The time zone {0} contains invalid data.", tzName), 
            ex2); 
   }      
}
Private Sub HandleInnerException()
   Dim timeZoneName As String = "Any Standard Time"
   Dim tz As TimeZoneInfo
   Try
      tz = RetrieveTimeZone(timeZoneName)
      Console.WriteLine("The time zone display name is {0}.", tz.DisplayName)
   Catch e As TimeZoneNotFoundException
      Console.WriteLine("{0} thrown by application", e.GetType().Name)
      Console.WriteLine("   Message: {0}", e.Message)
      If e.InnerException IsNot Nothing Then
         Console.WriteLine("   Inner Exception Information:")
         Dim innerEx As Exception = e.InnerException
         Do
            Console.WriteLine("      {0}: {1}", innerEx.GetType().Name, innerEx.Message)
            innerEx = innerEx.InnerException
         Loop While innerEx IsNot Nothing
      End If            
   End Try   
End Sub

Private Function RetrieveTimeZone(tzName As String) As TimeZoneInfo
   Try
      Return TimeZoneInfo.FindSystemTimeZoneById(tzName)
   Catch ex1 As TimeZoneNotFoundException
      Throw New TimeZoneNotFoundException( _
            String.Format("The time zone '{0}' cannot be found.", tzName), _
            ex1) 
   Catch ex2 As InvalidTimeZoneException
      Throw New InvalidTimeZoneException( _
            String.Format("The time zone {0} contains invalid data.", tzName), _
            ex2) 
   End Try      
End Function

설명

일반적으로 클래스의 이 오버로드를 InvalidTimeZoneException 사용하여 에서 예외를 처리합니다.trycatch 블록. 매개 변수는 innerException 블록에서 처리되는 예외 개체에 catch 대한 참조이거나 일 수 있습니다 null. 이 값은 개체의 InnerException 속성에 InvalidTimeZoneException 할당됩니다.

문자열이 message 속성에 Message 할당됩니다. 문자열은 현재 문화권에 대해 지역화되어야 합니다.

적용 대상