Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.0 C#3.0
I have a function
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 7-Apr-13 7:52am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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)
Email_Sender(insert, id, _SuppressMessage: suppress);
Cheers
Andi
  Permalink  
Comments
Pheonyx at 7-Apr-13 18:46pm
   
Excellent response, my +5
Andreas Gieriet at 7-Apr-13 19:45pm
   
Thanks for your 5!
Cheers
Andi
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Just create an overload, so you can simply call whichever you want:
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);
}
  Permalink  
v2

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

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 Zoltán Zörgő 99
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 7 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100