how can i know whether an optional parameter is passed or not?
-
thanks.
-
thanks.
How about explaining it in detail?
Navaneeth How to use google | Ask smart questions
-
thanks.
If it is there then it is passed...
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
-
thanks.
-
thanks.
-
How about explaining it in detail?
Navaneeth How to use google | Ask smart questions
basically, i can achieve it by having an overloaded funciton, but, it is just a small issue that i do not want to have another overload of the function. I am having a funciton with 2 parameters and now i want to introduce a 3rd optional parameter. I just want to know whether the caller of the function passed the 3rd argument or not?
-
basically, i can achieve it by having an overloaded funciton, but, it is just a small issue that i do not want to have another overload of the function. I am having a funciton with 2 parameters and now i want to introduce a 3rd optional parameter. I just want to know whether the caller of the function passed the 3rd argument or not?
Simple When declaring an optional parameter you have to give it a default value. Just check if the value is different than the default, if it is it was passed, if its the same it wasn't.
-
Simple When declaring an optional parameter you have to give it a default value. Just check if the value is different than the default, if it is it was passed, if its the same it wasn't.
dude! Default parameter specifiers are not permitted in C#!!! http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85556.aspx[^]
-
Hi, dude, optional keyword is for VB.net, not C#.
:) I Love KongFu~
-
basically, i can achieve it by having an overloaded funciton, but, it is just a small issue that i do not want to have another overload of the function. I am having a funciton with 2 parameters and now i want to introduce a 3rd optional parameter. I just want to know whether the caller of the function passed the 3rd argument or not?
abhiram_nayan wrote:
now i want to introduce a 3rd optional parameter.
Would you please paste the code? I really do not know how to do this...
:) I Love KongFu~
-
There is nothing like optional parameter in C#.
Time is the best teacher; unfortunately it kills all of its students. जय हिंद
-
thanks.
Can't do that until C# 4.0 which hasn't been released yet.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) -
Can't do that until C# 4.0 which hasn't been released yet.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)this means, i should go with an overloaded function, that's it?!
-
this means, i should go with an overloaded function, that's it?!
If there is not anything that stops you from adding another overload (such as conflicting signature with another overload), yes. Alternatively, you can mimic an optional parameter by addin a parameter that accepts null values, and using a default value in the method body if null has been received.
-
Can't do that until C# 4.0 which hasn't been released yet.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)In reference to C# 4.0, I was just curious, would it be possible to know if an optional parameter was passed or no ? If we did not pass the value, it would take the default value which is defined. But how will the body know if the optional parameter was passed or no ?
-
In reference to C# 4.0, I was just curious, would it be possible to know if an optional parameter was passed or no ? If we did not pass the value, it would take the default value which is defined. But how will the body know if the optional parameter was passed or no ?
-
Well, it will not know. It will use the default value without worring if it was passed by the caller or automatically used. The whole point of optional parameters is to make that logic transparent to the method implementation.
-
dude! Default parameter specifiers are not permitted in C#!!! http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85556.aspx[^]
-
In Microsoft published Framework 2.0, few examples exists when you need to passing optional parameters... i haven't book with me now but i know it is possible. I'll show you examples later bec i already used it.... Thanks Naresh Prakash
-
In Microsoft published Framework 2.0, few examples exists when you need to passing optional parameters... i haven't book with me now but i know it is possible. I'll show you examples later bec i already used it.... Thanks Naresh Prakash