{"id":685,"date":"2010-08-12T15:51:54","date_gmt":"2010-08-12T10:21:54","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=685"},"modified":"2010-08-12T15:51:54","modified_gmt":"2010-08-12T10:21:54","slug":"static-class","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/microsoft\/csharp\/static-class\/","title":{"rendered":"Static class"},"content":{"rendered":"<p>C# introduced a new feature known as <strong>Static Class.<\/strong><\/p>\n<p>A class which has only Static Methods is known as Static Class.<\/p>\n<p><strong>Benefit of Static Class:<\/strong><\/p>\n<ul>\n<li>Object of static class cannot be created.<\/li>\n<li>All methods and members can be accessed by class Name.<\/li>\n<\/ul>\n<p><strong>Note : <\/strong><\/p>\n<ul>\n<li>All methods of static class must be specified explicitly by keyword static.<\/li>\n<li>Static class cannot have instance constructor but it can have Static Constructor.<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n\nusing\u00a0System;\nstatic\u00a0class\u00a0Shape\n {\n    public\u00a0static\u00a0double\u00a0GetArea(double\u00a0Width,\u00a0double\u00a0height)\n    {\n        return\u00a0Width * Height;\n    }\n }\n\nclass\u00a0Ractangle\n{\n   private\u00a0void\u00a0GetRactangleArea()\n   {\n     Double\u00a0Area;\n     Area =\u00a0Shape.GetArea(10, 5);\n   }\n }\n\n<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<p>In above Example Shape is Static class and contains static method named GetArea().<\/p>\n<p>And other class (Rectangle) access the GetArea() method without creating the instance of class Shape.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Example of Static Class, its usage and benefits<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[22],"tags":[],"class_list":["post-685","post","type-post","status-publish","format-standard","hentry","category-csharp"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":545,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/static-block-static-variable-and-static-method\/","url_meta":{"origin":685,"position":0},"title":"Static Block, Static Variable and Static Method","author":"Jitendra","date":"July 5, 2010","format":false,"excerpt":"Infrormation about Static Block, Static Variable and Static Method in JAVA","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"static Block Static Method Static Variable","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2010\/07\/static-Block-Static-Method-Static-Variable.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1356,"url":"https:\/\/www.jitendrazaa.com\/blog\/microsoft\/csharp\/final-keyword-in-c-sealed-with-const-and-readonly\/","url_meta":{"origin":685,"position":1},"title":"Final Keyword in C# &#8211; sealed with const and readonly","author":"Jitendra","date":"April 7, 2011","format":false,"excerpt":"Example of Final Keyword in C# - sealed with const and readonly","rel":"","context":"In &quot;c#&quot;","block_context":{"text":"c#","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/microsoft\/csharp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1937,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/virtual-function-in-java\/","url_meta":{"origin":685,"position":2},"title":"Virtual Function in JAVA","author":"Jitendra","date":"April 8, 2011","format":false,"excerpt":"Example and explanation of Virtual Function in JAVA","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1638,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/exception-chaining\/","url_meta":{"origin":685,"position":3},"title":"Exception chaining in Java","author":"Jitendra","date":"March 14, 2011","format":false,"excerpt":"Concept of Exception chaining with example in JAVA","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"Exception Chaining","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/Exception-Chaining.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1629,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/nested-class-and-its-necessity-with-example\/","url_meta":{"origin":685,"position":4},"title":"Nested Class and its necessity with example","author":"Jitendra","date":"March 11, 2011","format":false,"excerpt":"Example and Introduction of Nested classes in JAVA and there Types","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"Nested Class in JAVA","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/Nested-Class-in-JAVA.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3411,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/apex-interview-question-salesforce-part-16\/","url_meta":{"origin":685,"position":5},"title":"Apex Interview Question \u2013 Salesforce &#8211; Part 16","author":"Jitendra","date":"July 28, 2013","format":false,"excerpt":"151. Give Sample Code Snippet of Apex that that will show that how Parent and Child record can be inserted in Single Statement ? Ans : It can be done with help of External Id. [java] Date dt = Date.today().addDays(7); Opportunity newOpportunity = new Opportunity(Name = 'shivasoft', StageName = 'Prospecting',\u2026","rel":"","context":"In &quot;Apex&quot;","block_context":{"text":"Apex","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/apex\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=685"}],"version-history":[{"count":0,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/685\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}