Hello!
I want to pass an argument that match both BlowStepEvent and
AdditionEvent.
I also want to have an argument that match both BlowStepCondEvent and
AdditionCondEvent.
I also want to have an argument that match both HandleBlowStepEvent and
HandleAdditionEvent.
Finally I want to have an argument that match both HandleBlowStepCondEvent
andHandleAdditionCondEvent.
It's like having an int type as formal parameter and as actual parameter I
can pass any whole number.
Assume we replace method addNewBlowStep and addNewAdditionStep with this
method called addNewStep below. So I wonder how should the type Sometype_1
and Sometype_2 and Sometype_3 and Sometype_4 look like. That is what I want.
Hope you understand what I mean.
addNewStep(ArrayList list, FlyGrid flygrid, Sometype_1 newArg_1,
Sometype_2 newArg_2, Sometype_3 newArg_3,
Sometype_4 newArg_4)
{
StringClass cond = new StringClass("", new ArrayList());
StringClass sc = new StringClass( "", list, cond );
sc.newArg_1 += new MyDelegateSignature( newArg_3);
cond.newArg_2 += new MyCondDelegateSignatur( newArg_4);
m_flygrid.AddRow( new object[] { sc, cond} );
}
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
skrev i meddelandet news:ug**************@TK2MSFTNGP06.phx.gbl...
Hi,
Frankly it's not very clear what you want to achieve.
Can you use an extra parameter to indicate which event you want to
handle?
you could create an enumerator for this situation
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"tony" <jo*****************@telia.comwrote in message
news:eX*************@TK2MSFTNGP06.phx.gbl...
>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