I have some old code from someone else that I need to fix so it builds again and one issue that I don't know how to fix, is constructor chaining. It looks something like this:
class Foo(){
public Foo()
{
int i = /*block of code*/;
this (i);
}
public Foo(int i)
{
//..
}
}
The error comes at the this (i);
line where it says Method, delegate, or event is expected
. Basically it no longer allows you to use this
as just a constructor anymore. Maybe it did in older version of C#.
What would be the appropriate way to fix this? I can replace public Foo()
with public Foo(): this(i)
but then it doesn't recognize the variable i
anymore.