T
Tony Johansson
Hello!
I'm reading in a book and sometimes they use the term declaration and
sometimes they use the term definition.
I just wonder if there exist any kind of definition about what exactly a
definition resp a declaration is?
For example here is an extract.
Notice that the StreamReader declaration was moved outside the Try block.
StreamReader sr = new StreamReader("text.txt");
try
{
Console.writeLine(sr.readToEnd());
}
catch(Exception ex)
{
....
}
One more thing in the book they say the following "Typically, all code
except for simple variable decaration should occur
within Try blocks."
If I for example have a method that just add "" to a string so string 1
become "1" doesn't need to be put into a Try catch block
I assume. Do you agree ?
//Tony
I'm reading in a book and sometimes they use the term declaration and
sometimes they use the term definition.
I just wonder if there exist any kind of definition about what exactly a
definition resp a declaration is?
For example here is an extract.
Notice that the StreamReader declaration was moved outside the Try block.
StreamReader sr = new StreamReader("text.txt");
try
{
Console.writeLine(sr.readToEnd());
}
catch(Exception ex)
{
....
}
One more thing in the book they say the following "Typically, all code
except for simple variable decaration should occur
within Try blocks."
If I for example have a method that just add "" to a string so string 1
become "1" doesn't need to be put into a Try catch block
I assume. Do you agree ?
//Tony