Part 11: C# Tutorial – Methods in C#

We will cover following points in this article

1. Why methods
2. Method Signature
3. Difference between static and instance methods
   

     Why Methods

1. Methods are also called as functions.
2. Method is a code block that contains a series of statements and used to define the
    behavior of a class.
3. Methods are extremely useful because they allow you to separate your logic into 
   different units. You can pass information to methods, have it perform one or more 
   statements, and retrieve a return value. 
4. Methods make application maintenance easier. 

Methods Signature 

< attributes> 
<accessmodifiers> <return-type> <method-name> (<parameters>) 
{        
    //method body 
} 
<access modifiers> - public, private, protected, internal, protected internal 
<return-type>          - void or any valid data type 
<method-name>     - can be any meaningful name except reserved keyword <parameters>         - are optional 

Static vs Instance methods 

1. Static methods are declared using static modifier. Static methods are invoked using 
    the class name. 
2.  Instance methods are declared without using the static modifier. Instance methods 
     are invoked using the instance of the class. 
3. A static method cannot access non-static class level members
4. Instance methods can access static fields. 
5. If a method is declared as static then only one definition of the static method exists in 
    the memory. Multiple instances/objects of a single class can invoke only one       
    definition of the static methods but each objects will have its own separate instance 
    methods.

Comments

  1. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    rpa training in velachery| rpa training in tambaram |rpa training in sholinganallur | rpa training in annanagar| rpa training in kalyannagar

    ReplyDelete
  2. This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
    Java training in Chennai | Java training in Bangalore

    Java online training | Java training in Pune

    ReplyDelete
  3. Thanks for sharing such a useful post and i hope it’s useful to many people for developing their skill .Thanks a lot.
    aws online training
    aws training in hyderabad
    aws online training in hyderabad

    ReplyDelete
  4. I am a regular reader of your blog and being students it is great to read that your responsibilities have not prevented you from continuing your study and other activities. Love
    Microsoft Azure online training
    Selenium online training
    Java online training
    Python online training
    uipath online training

    ReplyDelete
  5. Thanks a lot for sharing such a good source with all, i appreciate your efforts taken for the same. I found this worth sharing and must share this with all.



    Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery











    ReplyDelete
  6. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
    Java training in Chennai

    Java training in Bangalore

    Java training in Hyderabad

    Java Training in Coimbatore

    Java Online Training

    ReplyDelete
  7. Greetings. I know this is somewhat off-topic, but I was wondering if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot.
    web designing training in chennai

    web designing training in omr

    digital marketing training in chennai

    digital marketing training in omr

    rpa training in chennai

    rpa training in omr

    tally training in chennai

    tally training in omr

    ReplyDelete

Post a Comment