473,327 Members | 2,103 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,327 software developers and data experts.

clarification is needed

Hi,

Please let me know is ther any way to pass some default parameters to a
Method in C-Sharp without overloading the Method.
In VB we can done the above with the help of optional parameter . What's
the Equvelent in C-Sharp.

Note : Without Method OverLoading.

can you give me some sample.

Regards,
R.Baskar
c
Nov 15 '05 #1
4 1204
What's the problem with method overloading ?
Actually, it's the only solution.
The framework does it all over the place.
You don't have to worry about the extra method and extra
method call.

Greetings,
BV.

-----Original Message-----
Hi,

Please let me know is ther any way to pass some default parameters to aMethod in C-Sharp without overloading the Method.
In VB we can done the above with the help of optional parameter . What'sthe Equvelent in C-Sharp.

Note : Without Method OverLoading.

can you give me some sample.

Regards,
R.Baskar
c
.

Nov 15 '05 #2
100
I's too boring. If I have method and I want to have for say 3 of the
parameters default values I have to make 3 dummy overloads. Those overloads
pollute the code and make the source files bigger.
It's a shame that c# doesn't have default parameters. I don't warry about
the performance hopefully calls to those methods will be inlined by the
JITter.
I think default parametters are not CLI compliant, but we may still benefit
from them for internal stuff.

B\rgds
100

<an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
What's the problem with method overloading ?
Actually, it's the only solution.
The framework does it all over the place.
You don't have to worry about the extra method and extra
method call.

Greetings,
BV.

-----Original Message-----
Hi,

Please let me know is ther any way to pass some

default parameters to a
Method in C-Sharp without overloading the Method.
In VB we can done the above with the help of optional

parameter . What's
the Equvelent in C-Sharp.

Note : Without Method OverLoading.

can you give me some sample.

Regards,
R.Baskar
c
.

Nov 15 '05 #3
Make a struct with the parameters and pass the struct to your method

"100" <10*@100.com> schrieb im Newsbeitrag
news:uB**************@TK2MSFTNGP09.phx.gbl...
I's too boring. If I have method and I want to have for say 3 of the
parameters default values I have to make 3 dummy overloads. Those overloads pollute the code and make the source files bigger.
It's a shame that c# doesn't have default parameters. I don't warry about
the performance hopefully calls to those methods will be inlined by the
JITter.
I think default parametters are not CLI compliant, but we may still benefit from them for internal stuff.

B\rgds
100

<an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
What's the problem with method overloading ?
Actually, it's the only solution.
The framework does it all over the place.
You don't have to worry about the extra method and extra
method call.

Greetings,
BV.

-----Original Message-----
Hi,

Please let me know is ther any way to pass some

default parameters to a
Method in C-Sharp without overloading the Method.
In VB we can done the above with the help of optional

parameter . What's
the Equvelent in C-Sharp.

Note : Without Method OverLoading.

can you give me some sample.

Regards,
R.Baskar
c
.


Nov 15 '05 #4
100
Hi,
No, struct won't do. Why?
1. This is not what we want to do. It makes the code unclear. I don't have
method with default parameters. What I have is method with a mandatory
parameter of some struct type .
2. I can't have default values for the structure fields, because I can't
have a default constructor (thus I can't have initializing expressions in
the fields' declarations) . Because of the latter I have to make as many
overloads of that structure's constructor as many defaults parameters I
have. So, where is the benefit?. Better to overload my method.

Classes doesn't have these disadvantages, but classes are reference types,
which opposites the nature of the parameters, which are local copies of the
actual ones passed to the function.

Again, why we have to workaround something which has to be feature of any
modern language I believe?

B\rgds
100

"Zürcher See" <aq****@cannabismail.com> wrote in message
news:10***************@fuchs.cyberlink.ch...
Make a struct with the parameters and pass the struct to your method

"100" <10*@100.com> schrieb im Newsbeitrag
news:uB**************@TK2MSFTNGP09.phx.gbl...
I's too boring. If I have method and I want to have for say 3 of the
parameters default values I have to make 3 dummy overloads. Those

overloads
pollute the code and make the source files bigger.
It's a shame that c# doesn't have default parameters. I don't warry about the performance hopefully calls to those methods will be inlined by the
JITter.
I think default parametters are not CLI compliant, but we may still

benefit
from them for internal stuff.

B\rgds
100

<an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
What's the problem with method overloading ?
Actually, it's the only solution.
The framework does it all over the place.
You don't have to worry about the extra method and extra
method call.

Greetings,
BV.
>-----Original Message-----
>Hi,
>
> Please let me know is ther any way to pass some
default parameters to a
>Method in C-Sharp without overloading the Method.
>In VB we can done the above with the help of optional
parameter . What's
>the Equvelent in C-Sharp.
>
>Note : Without Method OverLoading.
>
>can you give me some sample.
>
>Regards,
>R.Baskar
>
>
>c
>
>
>.
>



Nov 15 '05 #5

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

Similar topics

5
by: ma740988 | last post by:
Consider a number of instances of template class vector<a>, vector<b> ..., vector<f> The types are - of course different. Of interest is an efficient way to access them at runtime. One...
8
by: Victor | last post by:
I need a JavaScript timer - I have five events I need to time, that can be triggered by a mouseclick event, or a keypress event. Each event is separated by only one to two seconds. The first...
15
by: deko | last post by:
With all due respect to Stan Leszynski and Greg Reddick, I'm still wondering how to name controls on forms in my Access MDB. Correct me if I'm wrong... If a textbox or other control on a form...
21
by: aegis | last post by:
7.4#1 states The header <ctype.h> declares several functions useful for classifying and mapping characters.166) In all cases the argument is an int, the value of which shall be representable as an...
8
by: Sai Kit Tong | last post by:
In the article, the description for "Modiy DLL That Contains Consumers That Use Managed Code and DLL Exports or Managed Entry Points" suggests the creation of the class ManagedWrapper. If I...
3
by: Jon Booth | last post by:
I have just started programming .NET having come from ASP. We used to create a connection and store it in a session.This meant for each user logging into the site there was only one connection ...
3
by: Lerp | last post by:
Hi all, I have a developer that likes to work using all code behind forms no matter the size of the page, whereas I don't usually use this format. Today when I went to remove a field from one...
4
by: vivekian | last post by:
Hi, Have this following hierarchy which am implementing for a networking program. The base class 'ASocket' is the base class from which 'AListener' and 'ATalker' inherit . None of the functions...
2
by: ravir | last post by:
Hi, I am new to this group. I am working in Perl and shellscripts. I have a clarification regarding perl grep and pattern matching. I am writing a perl script to automate the process of code...
51
by: fjm | last post by:
Hey everyone. I'm back in search of a better understanding of OOP. I feel like these past couple of months have paid off for me because I am at a point where I am really beginning to understand how...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.