Technology Guruu

  • Home
  • Site Info
    • About Us
    • Disclaimer
    • Privacy Polacy
  • Home
  • Digital Marketing
    • SEO
    • SMM
    • SEM
  • Quotes
  • Technical
  • Java
  • .Net
    • C#.Net
    • ASP.Net
  • Keychains

Friday, 11 November 2016

Passing Parameter Mechanism in C#.Net and Java

 Akansha     12:00:00     C#.Net, Java, TechnicalQuestions     No comments   

After Listening about the topic passing parameter mechanism in C#.net, first i feel very difficult but after reading and doing some practical examples i feel very easy.The Parameter passing mechanism plays key role in program development so first concentrate on some tips for parameter passing.Here i am not only placing definition i place My practically doing examples.
Here i Covering the topics are Introduction about parameter passing,what is parameter, how parameter helpful to us,types parameter passing, and types of parameter passing mechanism.
Actually the passing parameter mechanism same in C#.net and Java but the examples are different.C#.net develpers just follow this concept and Java developers or learners just modify your examples in java process.
Passing Parameter mechanism

Passing Parameter Mechanism 

Parameter Passing easy to understand But when develop C#.Net program at that time confusion is came Which Parameters is pass or at this time parameter passing is necessary or not.so,you want get more clarity on parameter passing we simply develop any project with short period so,friends please concentrate on the below topic i write clear description about parameter passing i hopeful it is understand to all and also helpful in interview purpose.
                          *****Introduction about Parameters*****

Introduction about Parameter

Passing a value to function is called as passing parameter mechanism

What is parameter?

A variable which is declared with in the method signature is called as parameter.

Why Parameter?

Whenever a method is required some value for it's functionality from outside we will go for parameter.                    

Types of Parameters:-

               In C#.net we have two types of parameters.
1.Formal Parameter
2.Actual Parameter
  *****Types of parameters*****

1.Formal Parameter

         called function parameter is formal parameter.
 *****Formal Parameters*****

2.Actual Parameter

         Calling function parameter is actual parameter.
Ex;-class Myclass
{
internal void add(int a,int b)//called function,formal parameters
{
int c=a+b;
Console.WriteLine("result is:"+c);
}
}
class Program
{
static void Main()
{
Myclass obj= new Myclass();
int x=10;
int y=20;
obj.add(x,y);//calling function,actual parameters
}
}
**************Actual Parameters*****************
C#.net will support three types of passing parameter mechanism
1.Call by value
2.Call by reference
3.Call by out

1.Call by value

In call by value when formal parameters are modified the modifications will not be reflected back to actual parameters.
In call by value while passing the parameter we will pass the actual value.
Ex:-class Myclass
{
intenal void PayFee(int a)
{
a=a+1500;
Console.WriteLine("a value is:+a);
}
}
class Program
{
static void Main()
{
Myclass obj=new Myclass();
int x=1000;
obj.PayFee(x);
Console.WriteLine("X value is:"+x);
Console.ReadLine();
}
}
*****call by value in parameter passing*****

2.Call by reference

       In call by reference when formal parameters are modified those modifications will be reflecting back to actual parameters.
In call by reference while passing the parameter we will pass the address of value.
Ex:-class Myclass
{
intenal void Add(ref int a)
{
a=a+1500;
Console.WriteLine("a value is:+a);
}
}
class Program
{
static void Main()
{
Myclass obj=new Myclass();
int x=1000;
obj.Add(ref x);
Console.WriteLine("X value is:"+x);
Console.ReadLine();
}
}    *****call by reference parameter passing*****

3.Call by out

call by out is same as call by reference,In call by out also when formal parameters are modified those modifications will be reflecting back to actual parameter.
While passing parameter or while catching parameter we should use out keyword.
In call by out also with the help of parameter we will pass the address.
out parameter is not required to initialize,If we initialize also CLR will ignore that value.
Ex:-class Myclass
{
internal void PayFee(out int totfee)
{
int admFee=1500;
int semFee=1200;
totFee=admFee+semFee;
Console.WriteLine("total fee is:"+totFee);
}
}
class Program
{
void Main()
{
Myclass obj=new Myclass();
int x;
obj.PayFee(out x);
Console.WriteLine("x value is:+x);
Console.ReadLine();
}
}        *****call by out parameter passing*****
Are you Looking For More Topics on C#.Net please visit My Previous Post i feel those are helpful to you
Introduction about Methods in C#.Net
Exception handling Mechanism explanation
Logical Programming Examples on whileloop
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Popular Posts

  • Brief description about Delegates
    Introduction about delegates and why delegates are came the main purpose of delegates how to useful and what are the advantages and disadv...
  • Missing My Friend Quotes : Friendship Day Quotes 2017
    Friends today my article about missing friends and moments with them. Here you are seen the best friendship quotes and some  feelings when...
  • Na Tanu Samjhawan Ki Song lyrics
    Na Tanu Samjhawan Ki Song Lyrics With English Translation Movie : Humpty Sharma ki Dulhaniya Song : Samjhawan Song Singer : Arijit ...
  • Detail Introduction about C#.Net
    Brief Introduction about C#.Net  Introduction C#.Net is the one of the Programming Language the .Net Framework also contains ano...
  • Love Failure Quotes and Sad valentines day Quotes
    We Love Someone is a easy process sometime takes long time to love someone love others within short period but anyway always love dependin...
  • Top 10 valentine's day Quotes and Greetings wishes
    All Lovers have Anxiety in Valentines day because it is a festival to all lovers in these they enjoy a lot and celebrate the Valentine...
  • Wonderful sayings about Life.
    I Believe Follow  Things(Life Quotes) I Believe I believe: ********** Believe in Life ********** That we don't have to chan...
  • Brief Description about Multicast Delegate
    Multicast delegate is an extension of normal delegate. It helps you to point more than one method at a single moment of time. Multicast ...
  • Letter B wallpapers and keychains for facebook
    In these we are Providing Letter B Wallpapers and awesome Key chains also Some Facebook Profile Pictures and cover photos also we are prov...
  • Best Good Afternoon wishes greetings and quotes
    Top Most Good Afternoon Wishes Good Afternoon wishes are gives a relaxation in afternoon time.This wishing can be done between 12 to 3 p...

Categories

  • Entertainment (67)
  • TechnicalQuestions (58)
  • Quotes (11)
  • C#.Net (8)
  • Java (8)
  • ValentinesDay (4)
  • SEO (3)
  • Home
  • About Us
  • Disclaimer
  • Privacy Policy
  • Sitemap

Copyright © 2015-2017 Good Friends 5.All Rights Reserved• And Our Sitemap • All Logos and Trademark Belongs To Their Respective Owners•