Skip to main content

C # Tutorial, Methods

 Hello, Welcome to C# Tutorial. My name is Abdul Yesdani. Today we are going to learn about methods in C# programing language.

Method is a bunch of code or statements which perform a single task. Here you can see the method example.

    static void Hello(string name)

        {

            Console.WriteLine("Hello!" + name +"  Welcome to C#");

            Console.WriteLine("Methods can have n number of statements");

            Console.WriteLine("method will perform a single task");

        }

Methods can have parameters as shown in the above example, 'string name' is a parameter must be passed its value at the calling method in side the Main() method.




Press Ctrl+ F5 to run the application. You will get the following output.



In the above example you can see 'void'  keyword before method name. Means method return type is void , i.e., method returns nothing. We can return any type through a method, It can be an int type, double type, string type or any other type.

The following example is showing  Add2Numbers(int no1, int no2)  method which is returning a value.


Run the application by pressing Ctrl + F5 keys. You will get the following output.


Methods are basic building blocks in side a class in any application .

*Please help us to improve the tutorial by commenting in the comment section. 


Comments

Popular posts from this blog

Every day Hands on Exercises / Assignments

Day wise hands on exercises/ assignments Day 1: HTML Hands on Exercises Date:04-10-2021 1.Create a web page to display your name, designation, location. 2. Create a web page to show about yourself in 3, 4 paragraphs. 3. Create a web page to display some nature images and Describe those images. 4.create a web page about college anniversary celebrations Divide your page in 4, 5 div elements . In the 1st div, put the heading of college , and display other details about the college. In the second div put images of the college. In third div put details of celebrations in paragraphs In the fourth div display the guest list. Use style attribute for doing color, background color, font etc, To emphasise some special content use elements like , 5. Create a web app on Indian cultural festivals. Use semantic elements for lay out of the page. Define an external style sheet and link with the page. Your app should have indexpage, cultural page, about us page. You should navigate amon...

.Net Presentation

.NET is a free, cross-platform, open source developer platform for building many different types of applications. With .NET, you can use multiple languages, editors, and libraries to build for web, mobile, desktop, games, and IoT. You can write .NET apps in C#, F#, or Visual Basic. C# is a simple, modern, object-oriented, and type-safe programming language. F# is a programming language that makes it easy to write succinct, robust, and performant code. Visual Basic is an approachable language with a simple syntax for building type-safe, object-oriented apps. You can write .NET apps in C#, F#, or Visual Basic. C# is a simple, modern, object-oriented, and type-safe programming language. F# is a programming language that makes it easy to write succinct, robust, and performant code. Visual Basic is an approachable language with a simple syntax for building type-safe, object-oriented apps.

CI / CD introduction

CI and CD are two acronyms used in modern development practices and DevOps. CI stands for continuous integration, a fundamental DevOps best practice where developers frequently merge code changes into a central repository where automated builds and tests run. But CD can either mean continuous delivery or continuous deployment. Continuous integration: Developers practicing continuous integration merge their changes back to the main branch as often as possible. The developer's changes are validated by creating a build and running automated tests against the build. By doing so, you avoid integration challenges that can happen when waiting for release day to merge changes into the release branch. Continuous integration puts a great emphasis on testing automation to check that the application is not broken whenever new commits are integrated into the main branch. Continuous delivery is an extension of continuous integration since it automatically deploys all code changes to a testing...