Search
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Articles Author
Wed, 27-Aug-2014 Authors
Goud.Kv
250
All Time Authors
Sourav.Kayal
39750
Sheonarayan
37300
Niladri.Biswas
33350

Latest members | More ...


(Statistics delayed by 5 minutes)
Ads
 Article

Static Keyword in C#

Ganeshji
Posted by under C# category on for Beginner level | Points: 250 | Views : 24664 red flag
If you found plagiarised (copied) or inappropriate content,
please let us know the original source along with your correct email id (to communicate) for further action.
Rating: 4.67 out of 5
3 vote(s)
This article is written to show the use of static keyword in csharp.

 Download source code for Static Keyword in C#



Static Keyword.


  1. A static method can access only static fields.
  2. A static method cannot access non-static fields.
  3. A static method cannot be called using object of a class.
  4. A static method can be called using Class name.
  5. Static fields can be used using Class Name.

A static method can access only static fields.





A static method cannot access non-static fields







Error Message




A static method cannot be called using an object of a class

Usually intellisense gives the list of method names available for a particular object. But here intellisense cannot show any user defined method.




A static method can  be accessed using Class Name


Here Intellisense has the respective method name of the particular class.




Output





Static fields can be accessed using Class Name





Output






Happy Coding!

Page copy protected against web site content infringement by Copyscape
About the Author

Ganeshji

Full Name: Zinnia Sarkar
Member Level:
Member Status: Member
Member Since: 7/24/2010 12:50:40 PM
Country: India
Regards, Ganeshji

Login to vote for this post.
Found interesting? Add this to:


Comments or Responses

Posted by: Karthikanbarasan on: 2/17/2011 | Points: 25

Good one!!!

Posted by: Karthikanbarasan on: 2/17/2011 | Points: 25

Please upload the code as well!!!!

Posted by: Ganeshji on: 2/17/2011 | Points: 25

Yes! I shall upload its code also.

Posted by: Madhu.b.rokkam on: 2/17/2011 | Points: 25

Nice article :)

Posted by: Jadugar on: 2/18/2011 | Points: 25

nice one!!thanks

Posted by: Bugwee on: 2/18/2011 | Points: 25

good article :)

Posted by: Tripati_tutu on: 2/19/2011 | Points: 25

Basic concepts are there and good one for all......

Posted by: Ganeshji on: 2/25/2011 | Points: 25

Thnx! All. Plz keep on suggesting me. Thnx agn!

Posted by: Akiii on: 7/19/2011 | Points: 25

good article.........
keep posting....

Thanks and Regards
Akiii

Posted by: Ganeshji on: 7/19/2011 | Points: 25

Thnx Akii!

Login to post response

Comment using Facebook(Author doesn't get notification)