473,394 Members | 1,769 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,394 software developers and data experts.

Default value for parameters

S K
Is it possible to give default values for parameters ?

like void func(int x, int y = 0);

Thanks
Nov 15 '05 #1
2 25497
Not in C#. You will have to use method overloading. Such as:

void func(int x)
{
func(x,0)
}

void func(int x, int y)
{
....
}
"S K" <so*****@zahoo.com> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
Is it possible to give default values for parameters ?

like void func(int x, int y = 0);

Thanks

Nov 15 '05 #2
S K
Thanks
"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:OM**************@tk2msftngp13.phx.gbl...
Not in C#. You will have to use method overloading. Such as:

void func(int x)
{
func(x,0)
}

void func(int x, int y)
{
...
}
"S K" <so*****@zahoo.com> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
Is it possible to give default values for parameters ?

like void func(int x, int y = 0);

Thanks


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Patrick Kowalzick | last post by:
Dear all, I have a question about default template parameters. I want to have a second template parameter which as a default parameter, but depends on the first one (see below). Is something...
11
by: BRG | last post by:
I know that default template arguments cannot be used in function templates but are default function parameters legal? That is, is this: ---------------------------------- #include <functional>...
4
by: S. van Beek | last post by:
Dear reader, By a Date field with Now() as default value the content of the field is date plus time. As I need a filter in a query on date only (excluding time) I invented the following...
1
by: Marco Martin | last post by:
Hi, I've got an oledb parameter that I'm sending to an Access DB. The table I'm sending it to has a column called "Zone" of type String that has a default value of "". So I create the...
2
by: confused | last post by:
Hi, I want to assign a default value of DBNull.Value to my stored procedure parameter, but also have the ability to overwrite it, so: SqlParameter param = new SqlParameter...
3
by: ruca | last post by:
Hi, How can I set a parameter of a function optinal and have a default value? In VB I do like this: Function myFunction (Optional ByVal bExist as Boolean = False) What's the equivalent in...
4
by: Shapper | last post by:
Hello, I work with Web Matrix and I created a DataSet which SQL Query uses the parameter Code in the URL: .... Dim dbParam_message_code As System.Data.IDataParameter = New...
2
by: Mark F. | last post by:
In VC++ you can preassign a default value to an argument passed to a function. CString GetLastName(BOOL bUpper = TRUE, CString sName) { // if the flag is omitted the return string is upper case...
0
by: stef mientki | last post by:
hello, I would like to use instance parameters as a default value, like this: class PlotCanvas(wx.Window): def __init__(self) self.Buf_rp = 0 self.Buf_wp = 0 def Draw ( self, x1 =...
8
by: William Xu | last post by:
Compiling: template <class T = int> T foo(const T& t) {} int main(int argc, char *argv) {} gcc complains:
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.