Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a function
SQL
public Email_Sender(Boolean _Activity_INSERT, String _OppID, List<String> attached_files = null,Boolean AutoSendEmail=false,String Mode_To_Send="Normal",Boolean _SuppressMessage=false)
     {}


I need to invoke the above function by skipping the default parameter (Mode_To_Send).
I need to provide value to the last parameter, how can i call the above function?


Prathamesh
Posted

Default parameters are not part of C# 3.0, they came into existence with C# 4.0 only.
So, I assume your tag for C# 3.0 should be C# 4.0.

You may call the function by
a) passing all actual arguments explicitly
b) pass the actual arguments by means of named parameters

E.g. for b)
C#
Email_Sender(insert, id, _SuppressMessage: suppress);

Cheers
Andi
 
Share this answer
 
Comments
Pheonyx 7-Apr-13 18:46pm    
Excellent response, my +5
Andreas Gieriet 7-Apr-13 19:45pm    
Thanks for your 5!
Cheers
Andi
Just create an overload, so you can simply call whichever you want:
C#
public Email_Sender(Boolean _Activity_INSERT, String _OppID, List<String> attached_files = null,Boolean AutoSendEmail=false,Boolean _SuppressMessage=false)
{
Email_Sender(_Activity_INSERT, _OppID, attached_files, AutoSendEmail, "Normal", _SuppressMessage);
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900