+ 5
Is it possible that even if we pass arguments to the function but still we want to use default value only
3 Respostas
+ 1
define default value globally
+ 1
Maybe add second argument with default value. But that would be confusing after revising the code after a while. So there are two ways - define variable inside function and add good comment to it so you temember why you did it or if it is an important value, make it public const or readonly variable.
+ 1
This would probably be a good spot to have a compiler directive in place so you can test with it, but when you compile for production, you can use the passed in values instead.
That way you can leave them on the code with comments and later disable them in one step, no matter how many there are.
example:
public void Some function(string paramA)
{
#if COMPILERVARIABLE
paramA ="override value";
#endif
//rest of function logic
}