Is it a bad practice to pass "this" as an argument?

Posted by Anna Lear on Stack Overflow See other posts from Stack Overflow or by Anna Lear
Published on 2010-03-16T16:33:37Z Indexed on 2010/03/16 16:41 UTC
Read the original article Hit count: 401

Filed under:
|
|

I'm currently tempted to write the following:

public class Class1() 
{
    public Class1() 
    {
        MyProperty = new Class2(this);
    }

    public Class2 MyProperty { get; private set; }
}

public class Class2() 
{
    public Class2(Class1 class1) 
    {
        ParentClass1 = class1;
    }

    public Class1 ParentClass1 { get; set; }
}

Is passing "this" as an argument a sign of a design problem? What would be a better approach?

© Stack Overflow or respective owner

Related posts about c#

Related posts about bad-practices