Tutorials
Resources
Forum
Reviews
Communities
Interview
Jobs
Projects
Training
Your
Ad
Here
Silverlight Games
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Polls
|
Revenue Sharing
|
Lobby
|
Gift Shop
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Alwyn
(42)
Abhisek Panda
(40)
Nadheera V
(40)
Last 7 Days
Alwyn
(706)
nishithraj
(512)
Gaurav Arora
(504)
more...
Resources
»
Articles
»
.NET Framework
»
Parameters in C#
Posted Date: 11 May 2006
Resource Type:
Articles
Category:
.NET Framework
Author:
Ramakrishna
Member Level:
Gold
Rating:
Points
: 5
Parameters in C#
Parameters:
Passing a values to the called function from the calling function
There are four different types of parameters in C#. They are
1. Value parameters
2. Ref parameters
3. Out parameters
4. Parameter arrays (Params)
1. Value parameters
A parameter declared with no modifiers is a value parameter and This is the default parameter type in C#. In this type of parametrs actual value is passed to the function, and the changes made in the function not affect the original value in the calling function.
Eg.
static void fnValue( int i)
{
i = i + 1;
}
2. Ref parameters
Ref parameters are input/output parameters. This type of parameters are declared with the modifier “ref” . these parameters are used to pass the values back and fourth between the called function and calling function. Here the actual reference of the variable is passed to the function.
static void fnRef( ref int i)
{
i = i + 1;
}
3. Out parameters
Out parameters are Similar to a reference parameter, these parameters are declared with the out modifier. Output parameters are typically used in methods that produce multiple return values. The out put parameters can only pass back a value from a function. Every output parameter of a method must be assigned before the method returns.
static void fnOut ( out int k, out int i )
{
k =5;
i=9;
}
4. Parameter arrays
This type parameters are declared with the modifier params. These types of parameters are very useful when we need to pass the number of arguments to the function. In the parameter list the parameter array must be the last parameter. and it must be of a single-dimensional array type. params parameters are input type parameters.
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
to add tags.
(No tags found.)
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
Introduction to .NET with Basic Shotcuts and Secrets for the Beginner
Previous Resource:
File uploading in asp.net using C# and diplaying in the grid
Return to Discussion Resource Index
Post New Resource
Category:
.NET Framework
Post resources and
earn money
!
More Resources
Introduction to .NET with Basic Shotcuts and Secrets for the Beginner
Assemblies - An Introduction
Generics in c# 2.0
How to Change the Image in datagrid based on a field in database
Covariant and contravariant delegates
Boxing and UnBoxing in C#
dotNet Slackers
About Us
Contact Us
Privacy Policy
Terms Of Use