{"id":22285,"date":"2013-05-13T11:32:51","date_gmt":"2013-05-13T06:02:51","guid":{"rendered":"http:\/\/vskills.in\/certification\/tutorial\/?p=22285"},"modified":"2024-04-12T14:16:47","modified_gmt":"2024-04-12T08:46:47","slug":"methods-the-main-method-and-parameter-passing","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/","title":{"rendered":"Methods, the main Method and Parameter Passing"},"content":{"rendered":"<h4><strong>Methods, the main Method and Parameter Passing<\/strong><\/h4>\n<p>In C#, a method is a block of code that performs a specific task. The main method is the entry point of a C# console application, where the program execution begins. It has a specific signature:<\/p>\n<p>csharp<\/p>\n<p>Copy code<\/p>\n<p>staticvoidMain(string[] args)<\/p>\n<p>The static keyword means that the method belongs to the class and not to any instance of the class. The void keyword indicates that the method doesn&#8217;t return any value. Main is the name of the method, and string[] args is an array of strings that represents the command-line arguments passed to the program.<\/p>\n<p>Parameter passing is the process of passing values to a method when it is called. C# supports three types of parameter passing:<\/p>\n<ol>\n<li>Value Parameters: This method passes a copy of the parameter value to the method. Any changes made to the parameter value inside the method do not affect the original value.<\/li>\n<li>Reference Parameters: This method passes the memory address of the parameter to the method. Any changes made to the parameter value inside the method will affect the original value.<\/li>\n<li>Output Parameters: This method is used to return more than one value from a method. An output parameter is a reference parameter that is declared using the out keyword. The method assigns a value to the output parameter, which is then returned to the caller.<\/li>\n<\/ol>\n<p>Here&#8217;s an example of a method that takes a value parameter:<\/p>\n<p>csharp<\/p>\n<p>Copy code<\/p>\n<p>publicstaticvoidAdd(int a, int b) { int result = a + b; Console.WriteLine(&#8220;Result: {0}&#8221;, result); }<\/p>\n<p>Here&#8217;s an example of a method that takes a reference parameter:<\/p>\n<p>csharp<\/p>\n<p>Copy code<\/p>\n<p>publicstaticvoidSquare(refint number) { number = number * number; Console.WriteLine(&#8220;Number squared: {0}&#8221;, number); }<\/p>\n<p>Here&#8217;s an example of a method that takes an output parameter:<\/p>\n<p>csharp<\/p>\n<p>Copy code<\/p>\n<p>publicstaticvoidDivide(int dividend, int divisor, outint quotient, outint remainder) { quotient<\/p>\n<div class=\"apply\">\n<h3>Apply for C Sharp Certification Now!!<\/h3>\n<p><a href=\"https:\/\/www.vskills.in\/certification\/Certified-C-sharp-Professional\" target=\"_blank\" rel=\"noopener\">https:\/\/www.vskills.in\/certification\/Certified-C-sharp-Professional<\/a><\/p>\n<h4><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/certified-c-professional\/\" target=\"_blank\" rel=\"noopener\"><strong>Back to Tutorial<\/strong><\/a><\/h4>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Methods, the main Method and Parameter Passing In C#, a method is a block of code that performs a specific task. The main method is the entry point of a C# console application, where the program execution begins. It has a specific signature: csharp Copy code staticvoidMain(string[] args) The static keyword means that the method&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[3351],"tags":[],"class_list":["post-22285","page","type-page","status-publish","hentry","category-c-sharp"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Methods, the main Method and Parameter Passing - Tutorial<\/title>\n<meta name=\"description\" content=\"Methods, the main method and parameter passing. Govt of India Certification for C#-Professional. Get Certified and improve employability. Certification assesses candidates in C#.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Methods, the main Method and Parameter Passing - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Methods, the main method and parameter passing. Govt of India Certification for C#-Professional. Get Certified and improve employability. Certification assesses candidates in C#.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:46:47+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/\",\"name\":\"Methods, the main Method and Parameter Passing - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2013-05-13T06:02:51+00:00\",\"dateModified\":\"2024-04-12T08:46:47+00:00\",\"description\":\"Methods, the main method and parameter passing. Govt of India Certification for C#-Professional. Get Certified and improve employability. Certification assesses candidates in C#.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Methods, the main Method and Parameter Passing\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Methods, the main Method and Parameter Passing - Tutorial","description":"Methods, the main method and parameter passing. Govt of India Certification for C#-Professional. Get Certified and improve employability. Certification assesses candidates in C#.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/","og_locale":"en_US","og_type":"article","og_title":"Methods, the main Method and Parameter Passing - Tutorial","og_description":"Methods, the main method and parameter passing. Govt of India Certification for C#-Professional. Get Certified and improve employability. Certification assesses candidates in C#.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:46:47+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/","name":"Methods, the main Method and Parameter Passing - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2013-05-13T06:02:51+00:00","dateModified":"2024-04-12T08:46:47+00:00","description":"Methods, the main method and parameter passing. Govt of India Certification for C#-Professional. Get Certified and improve employability. Certification assesses candidates in C#.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/methods-the-main-method-and-parameter-passing\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Methods, the main Method and Parameter Passing"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/22285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=22285"}],"version-history":[{"count":6,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/22285\/revisions"}],"predecessor-version":[{"id":132179,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/22285\/revisions\/132179"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=22285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=22285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=22285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}