Por que lançar exceção no construtor resulta em uma referência nula?
Por que lançar exceção no construtor resulta em uma referência nula? Por exemplo, se executarmos os códigos abaixo, o valor de teacher será null, enquanto st.teacher não será (um objeto Teacher será criado). Por quê?
<code>using System; namespace ConsoleApplication1 { class Program { static void Main( string[] args ) { Test(); } private static void Test() { Teacher teacher = null; Student st = new Student(); try { teacher = new Teacher( "", st ); } catch ( Exception e ) { Console.WriteLine( e.Message ); } Console.WriteLine( ( teacher == null ) ); // output True Console.WriteLine( ( st.teacher == null ) ); // output False } } class Teacher { public string name; public Teacher( string name, Student student ) { student.teacher = this; if ( name.Length < 5 ) throw new ArgumentException( "Name must be at least 5 characters long." ); } } class Student { public Teacher teacher; } } </code>