C# Constructor Question

Posted by Vaccano on Stack Overflow See other posts from Stack Overflow or by Vaccano
Published on 2010-04-13T23:17:24Z Indexed on 2010/04/13 23:23 UTC
Read the original article Hit count: 432

Filed under:
|
|

I have a constructor question for C#.

I have this class:

public partial class Signature : Form, ISignature
{
    private readonly SignatureMediator mediator;

    public Signature(SignatureMediator mediator)
    {
        this.mediator = mediator;
        InitializeComponent();
    }

    .... more stuff
 }

I want to construct this class like this:

    public SignatureMediator(int someValue, int otherValue, int thirdValue)  
       : this(new Signature(this), someValue, otherValue, thirdValue)
    // This is not allowed --^
    {
        // I don't see anyway to get this in to the ":this" part.
        //Signature signature = new Signature(this);

    }            


    public SignatureMediator(ISignature form, int someValue, int otherValue, int thirdValue)
    {
        SigForm = form;
        SomeValue= someValue;
        OtherValue= otherValue;
        ThirdValue= thirdValue;
    }

The : this( new SignatureThis(this) is not allowed (the this used in the constructor is not allowed).

Is there anyway to set this up without duplicating the assignment of the int values?

© Stack Overflow or respective owner

Related posts about c#

Related posts about c#3.0