Kurt
Regular
I wonder why the .ToString() methode of line 20 failes....
Some more questions;
1/ Is a string actually a value type or a reference type?
2/ If a string is a value type, what is the default initial value for the strings of an array of strings that is instantiated ("", null or String.Empty???)?
3/ And what is the value of the Exception.HelpLink string when not specified?
By the way, ToString() seems to work on String.Empty....
[CS]
namespace Tests
{
using System;
public class Test
{
public static void Main()
{
try
{
double a = 6;
double b = 0;
Console.WriteLine("{0} / {1} = {2}",a,b,Divide(a,b));
}
catch (DivideByZeroException divByZero)
{
//the folowing line WORKS, HelpLink property is seen as "" (empty string)
Console.WriteLine("Help on error: '{0}'\n\n",divByZero.HelpLink);
//the folowing line THROWS AN EXCEPTION, WHY ????
Console.WriteLine("Help on error: '{0}'\n\n",divByZero.HelpLink.ToString());
}
}
public static double Divide(double a, double b)
{
if (b == 0)
{
DivideByZeroException e = new DivideByZeroException("Argument b was 0 in DoDivision (dividing by zero)");
//folowing line is commented to see what the HelpLink property contains by default....
//e.HelpLink = "More about dividing by zero...";
throw e;
}
return a/b;
}
}
}
[/CS]
Some more questions;
1/ Is a string actually a value type or a reference type?
2/ If a string is a value type, what is the default initial value for the strings of an array of strings that is instantiated ("", null or String.Empty???)?
3/ And what is the value of the Exception.HelpLink string when not specified?
By the way, ToString() seems to work on String.Empty....
[CS]
namespace Tests
{
using System;
public class Test
{
public static void Main()
{
try
{
double a = 6;
double b = 0;
Console.WriteLine("{0} / {1} = {2}",a,b,Divide(a,b));
}
catch (DivideByZeroException divByZero)
{
//the folowing line WORKS, HelpLink property is seen as "" (empty string)
Console.WriteLine("Help on error: '{0}'\n\n",divByZero.HelpLink);
//the folowing line THROWS AN EXCEPTION, WHY ????
Console.WriteLine("Help on error: '{0}'\n\n",divByZero.HelpLink.ToString());
}
}
public static double Divide(double a, double b)
{
if (b == 0)
{
DivideByZeroException e = new DivideByZeroException("Argument b was 0 in DoDivision (dividing by zero)");
//folowing line is commented to see what the HelpLink property contains by default....
//e.HelpLink = "More about dividing by zero...";
throw e;
}
return a/b;
}
}
}
[/CS]