T
tony
Hello!
My problem is that I have several methods that is quite similar. Each one
works as they should.
You see two of them just below.
I have removed several statements that is not relevant for my question.
My idea is to have only one method and pass argument for things that differ
between the methods.
As you can see there isn't much that differ. It's two rows.
I don't know how to pass the things that differ. I have prefix those rows
that differ with the word "Diff"
Can you give example how I should write?
private void addNewBlowStep( ArrayList list, FlyGrid flygrid )
{
StringClass cond = new StringClass("", new ArrayList());
StringClass sc = new StringClass( "", list, cond );
Diff sc.BlowStepEvent += new MyDelegateSignature(HandleBlowStepEvent);
Diff cond.BlowStepCondEvent += new
MyCondDelegateSignature(HandleBlowStepCondEvent);
m_flygrid.AddRow( new object[] { sc, cond} );
}
private void addNewAdditionStep(ArrayList list, FlyGrid flygrid )
{
StringClass cond = new StringClass("",new ArrayList());
StringClass sc = new StringClass( "", list, cond );
Diff sc.AdditionEvent += new MyDelegateSignature(HandleAdditionEvent);
Diff cond.AdditionCondEvent += new
MyCondDelegateSignature(HandleAdditionCondEvent);
m_flygrid.AddRow( new object[] { sc, cond} );
}
//Tony
My problem is that I have several methods that is quite similar. Each one
works as they should.
You see two of them just below.
I have removed several statements that is not relevant for my question.
My idea is to have only one method and pass argument for things that differ
between the methods.
As you can see there isn't much that differ. It's two rows.
I don't know how to pass the things that differ. I have prefix those rows
that differ with the word "Diff"
Can you give example how I should write?
private void addNewBlowStep( ArrayList list, FlyGrid flygrid )
{
StringClass cond = new StringClass("", new ArrayList());
StringClass sc = new StringClass( "", list, cond );
Diff sc.BlowStepEvent += new MyDelegateSignature(HandleBlowStepEvent);
Diff cond.BlowStepCondEvent += new
MyCondDelegateSignature(HandleBlowStepCondEvent);
m_flygrid.AddRow( new object[] { sc, cond} );
}
private void addNewAdditionStep(ArrayList list, FlyGrid flygrid )
{
StringClass cond = new StringClass("",new ArrayList());
StringClass sc = new StringClass( "", list, cond );
Diff sc.AdditionEvent += new MyDelegateSignature(HandleAdditionEvent);
Diff cond.AdditionCondEvent += new
MyCondDelegateSignature(HandleAdditionCondEvent);
m_flygrid.AddRow( new object[] { sc, cond} );
}
//Tony