What are optional parameters in c#?
c#
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Oct 24, 2014, 11:51 AM EDT
For more detail, check this link:
http://msdn.microsoft.com/en-gb/library/dd264739.aspx
Wim SturkenboomRank #2,527 · 554 reputationPosted Oct 24, 2014, 11:52 AM EDT
public void MyMethod(string strFirstname, string strLastname)
When calling, you need to pass both parameters
public void MyMethod(string strFirstname, string strLastname="Sturkenboom")
When calling, you ony have to pass the first parameter; second parameter, if omitted in call, is set to a default.
aditya shukla67 reputationPosted Oct 24, 2014, 12:06 PM EDT