473,699 Members | 2,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Optional parameters in a procedure.

UJ
How do you make parameters optional in a procedure. I know I can have
multiple definitions but it would be nice if there was a way I could have
the single declaration. I thought there was a way to do that.

TIA - Jeff.
Dec 14 '05 #1
3 1273
overloading or sending null.

I do this alot

public void DoSomething(str ing a)
{
DoSomething(a, null);
}

public void DoSomething(str ing a, string b)
{
if(b == null)
// do something
else
// do something else
}

"UJ" <fr**@nowhere.c om> wrote in message
news:u$******** ******@tk2msftn gp13.phx.gbl...
How do you make parameters optional in a procedure. I know I can have
multiple definitions but it would be nice if there was a way I could have
the single declaration. I thought there was a way to do that.

TIA - Jeff.

Dec 14 '05 #2
No, not in C#. I believe that there is in VB.NET, though.

In C# you have to write overloads in order to get this effect.

Dec 14 '05 #3
UJ
OK. Thanks.

"Bruce Wood" <br*******@cana da.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
No, not in C#. I believe that there is in VB.NET, though.

In C# you have to write overloads in order to get this effect.

Dec 14 '05 #4

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

Similar topics

1
1535
by: yuliad | last post by:
How can I call stored procedure with optional parameters? Is it ODBC support naming notation for stored procedure parameters? I try to execute the following statement from the C++ program and catch the syntax error: call StorProcName( Param1Name => 1, Param2Name => 'Model' ) Thanks in Advance.
1
1653
by: ganesh wayachal via SQLMonster.com | last post by:
In which system table the information about the optional parameters passed to stored procedure are stored. I know about the tbl_columns and all that stuff. From where can i can come to know the parameter is mandatory or optional. -- Message posted via http://www.sqlmonster.com
16
4057
by: ad | last post by:
Does C#2.0 support optional parameters like VB.NET: Function MyFunction(Optional ByVal isCenter As Boolean = False)
2
1652
by: et | last post by:
I have the following function that uses an optional parameter, and it sets a default, as the program says I have to. Yet it doesn't pick up the default value. Why is this, what am I doing wrong. Public Function SelectQuery(strTbl as string, arr as ArrayList, Optional SortCol as string = "Yr desc") Calling procedure: qry = SelectQuery(strTbl, arr, SortCol)
7
13357
by: CK | last post by:
I want the procedure to check for the existence of a paramter and if it is there, it will process these instructions, otherwise it will process these instructions. Any ideas? Thanks for your advice. Regards, CK
14
3267
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 make things simpler and better readable I'd make all default parameters named parameters so that you can decide for yourself which one to pass and which not, rather than relying on massively overlaoded methods which hopefully provide the best...
4
1945
by: Mark Baldwin | last post by:
I have a web page with various controls that supply parameters to an ObjectDataSource. The ObjectDataSource has various methods that allow for filtering of the results...GetProductsByID(), GetProductsByIDAndDate()...etc Because the parameters are optional, I have to make a methods that take all variantions of these parameters, so if I have 3 parameters, I need 7 methods, I then have to write code to call the correct method depending on...
12
2665
by: pamelafluente | last post by:
Hi guys, In the past I have used several time optional parameters in my function. But Now I am more inclined to think that they are more dangerous than useful, and probably better to be avoided. I'd like to hear your various opinions on this matter.
9
2962
by: BillCo | last post by:
I'm new to SQL Server, so if I'm doing anything stupid don't be mean :) I have a procedure that I use to return data based on optional parameters. It works fine, except when the underlying data contains a null on one if the fields being searched. My system uses a default wildcard for all parameters, so this excludes such records. I need a way to add in " OR fldName IS NULL " where the parameter is empty or '%'. I've looked at using...
7
7057
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 As Integer = 0, _ Optional ByVal Arg2 As Integer = 0, _ Optional ByVal Arg3 As Integer = 0) ' Call my SQL proc with the same signature
0
8691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8620
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9180
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8887
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3060
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2012
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.