473,395 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Optional - Method Signature

144 100+
hi,

i'm kinda confuse about how the optional keyword relates to a method signature. as a method with optional parameters has multiple method signature

in VB.net if i declare the following method

Expand|Select|Wrap|Line Numbers
  1. Public Sub OptionalMethod(Optional ByVal arg1 As Integer = 1, Optional ByVal arg2 As Integer = 2, Optional ByVal arg3 As Integer = 3)
then i have four method signatures, which are OptionalMethod(), OptionalMethod(Integer), OptionalMethod(Integer, Integer) and OptionalMethod(Integer, Integer, Integer).

am i right?


thank you.
Oct 8 '08 #1
1 1536
shweta123
692 Expert 512MB
Hi,

Optional keyword is used if it is not necessary to send all the parameters to the function when you call that function. So when you use Optional keyword you have to assign default value to the parameter.In your case you can call OptionalMethod procedure in different ways.
e.g.
1> OptionalMethod()
2> OptionalMethod (1,2,3)
3> OptionalMethod (1,2)





hi,

i'm kinda confuse about how the optional keyword relates to a method signature. as a method with optional parameters has multiple method signature

in VB.net if i declare the following method

Expand|Select|Wrap|Line Numbers
  1. Public Sub OptionalMethod(Optional ByVal arg1 As Integer = 1, Optional ByVal arg2 As Integer = 2, Optional ByVal arg3 As Integer = 3)
then i have four method signatures, which are OptionalMethod(), OptionalMethod(Integer), OptionalMethod(Integer, Integer) and OptionalMethod(Integer, Integer, Integer).

am i right?


thank you.
Oct 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: sonu | last post by:
MSUK are you Samiulla khan, its sonu here you cannot pass optional parameters in C#, an overloaded method is the right way. But you must also remember that you cannot have methods with the...
16
by: ad | last post by:
Does C#2.0 support optional parameters like VB.NET: Function MyFunction(Optional ByVal isCenter As Boolean = False)
14
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.