What does method default parameter value mean?

Yoon, Young Hyun 41 Reputation points
2021-04-30T06:21:26.753+00:00

I really need a help. Thank you...!

Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2021-04-30T09:52:07.667+00:00

    Hello,

    If you are referring too using default for a parameter as per below

    public static void Write(string message, bool append = true, DateTime timestamp = default, decimal value = default)  
    {  
        Console.WriteLine($"{message}, {append}, {timestamp}, {value}");  
    }  
    
    • append parameter is optional with a predefined value
    • timestamp and value if not passed will be the default value for the type. For DateTime 1/1/0001 12:00:00 AM and decimal is 0.

    See also

    Optional Arguments and default value expressions.

    If the above does not answer your question please provide a small example to what you are looking at

    ---
    92858-kpmvp.png

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.