Clever answers do not seem to work, let's try the primitive ones. It's some
second week I am learning C#, so correct me, if I am wrong.
1) Is "this.arrTeachers.Count" actually a string? I bet, it is not.
Then it needs formatting like
Console.WriteLine("{0}",this.arrTeachers.Count);
2) As for ex.ToString, it is not going to be shown unless you introduce some
problem into "try" block. I bet you know that, don't you?
==============
BTW when I try to understand the logic of your checking that arrTeachers is
not null , I feel dizzy :-)
Suppose, arrTeachers really happens to be null. Then, the exception is
thrown at the point, where you tried to do the addition ("arrTeachers.Add
(p);"), because u cannot insert something into nothing ;-)
So, if arrTeachers is null, you NEVER reach the "if" statement to see if
arrTeachers is null.
So you check if arrTeachers is not null only in the case when arrTeachers is
definitely not null... %)
Hello, juzan!
You wrote on Sun, 4 Apr 2004 13:17:58 +1000:
j> hi i have this piece of code but it never shows the ex.tostring in
j> the command or immed window.
j> how do i see it?
j> this is in a class
j> public void getTeachers()
j> {
j> try {
j> PermTeacher p =new PermTeacher ();
j> p.name = "teacher1";
j> arrTeachers.Add (p);
j> if (arrTeachers !=null)
j> Console.WriteLine(this.arrTeachers.Count); //how can i see this?
j> }
j> catch(Exception ex)
j> {
j> Console.WriteLine(ex.ToString());
j> }
j> }
With best regards, Kozynenko Ganna. E-mail:
gk**@isd.dp.ua