473,405 Members | 2,354 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,405 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 25499
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.