static void Main() { Student stu = null; if (StudentFactory.Create("Tim", 23, out stu)) { Console.WriteLine("Student {0},age is {1}.", stu.Name, stu.Age); } }
static void Main(string[] args) { Student stu = null; bool b = StudentFactory.Create("Tim", 23, out stu); if (b == true) { Console.WriteLine("Student {0}, age is {1}.", stu.Name, stu.Age); } }