L
Laura T.
In the following example, c# 2.0 compiler says that a3 and ret are used
before assigned.
as far as I can see, definite assignment is made.
If I add
finally
{
ret = true;
a3 = "b3";
}
it compiles OK.
------ example -------
using System;
using System.Collections.Generic;
using System.Text;
namespace Scope
{
class Program
{
static void Main(string[] args)
{
string test;
Try(out test);
}
private static bool Try(out string Hello)
{
bool ret;
string a1, a2, a3;
try
{
for (int i = 0; i < 3; i++)
{
a1 = "1";
a2 = i.ToString() + a1;
a3 = "HELLO";
}
ret = true;
}
catch (Exception)
{
a3 = "sa";
}
Hello = a3;
return ret;
}
}
}
before assigned.
as far as I can see, definite assignment is made.
If I add
finally
{
ret = true;
a3 = "b3";
}
it compiles OK.
------ example -------
using System;
using System.Collections.Generic;
using System.Text;
namespace Scope
{
class Program
{
static void Main(string[] args)
{
string test;
Try(out test);
}
private static bool Try(out string Hello)
{
bool ret;
string a1, a2, a3;
try
{
for (int i = 0; i < 3; i++)
{
a1 = "1";
a2 = i.ToString() + a1;
a3 = "HELLO";
}
ret = true;
}
catch (Exception)
{
a3 = "sa";
}
Hello = a3;
return ret;
}
}
}