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

Monday, 31 October 2016

Brief Descriptions About Methods

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


Constructors and Methods are the heart for our programming languages like java,c#.net,vb.net etc Any developer first know the value of constructors and methods and what are the difference between method and constructors.How it can be placed in programming development.

Methods in C#.Net

methods
methods
According to parameters,methods are classified into two types
1.Parameterless method
2.Parameterize method

1.Parameterless method:-

While defining a method if we didn't declare any parameters which is called as parameterless method.

Q)When we will go for parameterless method?

Ans:According to method functionality if the method doesnot required any value then we will go for parameterless method.
EX:-class Program
{
void Display()
{
Console.WriteLine("welcome to c#.net");
Console.WriteLine("welcome to Asp.net" );
}
}

2.Parameterize method:-

While defining a method if we have declared parameter which is called as parameterized method.

Q)When we will go for parameterized method?

Ans:According to requirement whenever a method is required some value for it's functionality then we will go for parameterized method.
EX:-class Program
{
void add(int a,int b)
{
int c=a+b;
Console.WriteLine("result is:"+c);
}
}
According to method return types methods are classified in to two types
1.Void method
2.Non-Void method

1.Void method:-

A method which is not returning any value according to it's functionality is called as void
method.Void method return type should be void.

Q)When we will go for void method?

Ans:According to the requirement if the method does not require to return any value we will go for void method.

2.Non-Void method:-

A method which is returning some value is called as non-void method.

Q)When we will go for non-void method?

Ans:According to method functionality if it requires to return some value we will go for non-void method.the return type of method will be depending on type of the value which is returning by the method.If the method requires to return numerical values then method return type can be any one of the numerical data type like int,long,short............................
Ex:-int fun(int a)
{
return a;
}
char fun1(char a)
{
return a;
}
Again methods are classified into two types
1.Instance method or Non-static method
2.Static method

1.Instance method or Non-static method:-

While defining a method if we didn't use static keyword which is called as instance method.If we want to access instance method with the help of object.
Ex:-class Employee
{
ulong empid;
string empname;//instance variables
internal void Display()
{
Console.WriteLine("Enter employee id ");
ulong empid=ulong.Parse(Console.ReadLine());
Console.WriteLine("Enter employee name ");
string empname=Console.ReadLine();
Console.WriteLine("employee id is:"+empid);
Console.WriteLine("employee name is:"+empname);
}
}
class Program
{
static void Main(string args[])
{
Employee a=new Employee();
a.Display();//calling instance method
Console.ReadLine();
}
}

2.Static method:-

While defining a method if we are using static keyword which is called as static method.If we want to access static method we have to access with the help of class name.
Ex:-
class Employee
{
static string compname;
static string comploc;//static variables
static internal void Display()
{
compname="wipro";
comploc="Hyderabad";
}
}
class Program
{
static void Main(string args[])
{
Employee.Display();//calling static method
Console.ReadLine();
}
}
Methods topic in c#.net are most important to everyone so please share it to your friends also through facebook,twitter,google plus.
  • 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

  • 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...
  • 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...
  • 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...
  • 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 ...
  • 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...
  • 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...
  • 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...
  • 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...
  • 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 ...
  • How to Remove Audio From Any Video Using VLC Media Player?
    Step by Step Procedure for  Remove(Mute) Audio in a Video Using VLC  Player A picture is worth a thousand words and a video is worth a t...

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•