Get the App
SLTechnology News&Howtos  ›  Development  › 

How to call method in C #

Shulou Source: shulou.com Published: 2022-06-01 02:05:53 09月14日 Update

Most people do not understand the knowledge points of this article "how to call methods in C#", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to invoke methods in C#" article.

Calling method in C #

You can use the method name to call the method. The following example demonstrates this:

Example

Using System

Namespace CalculatorApplication

{

Class NumberManipulator

{

Public int FindMax (int num1, int num2)

{

/ * Local variable declaration * /

Int result

If (num1 > num2)

Result = num1

Else

Result = num2

Return result

}

Static void Main (string [] args)

{

/ * definition of local variables * /

Int a = 100

Int b = 200

Int ret

NumberManipulator n = new NumberManipulator ()

/ / call the FindMax method

Ret = n.FindMax (a, b)

Console.WriteLine ("Max is: {0}", ret)

Console.ReadLine ()

}

}

}

When the above code is compiled and executed, it produces the following results:

The maximum value is: more than 200 is about the content of this article on "how to call methods in C#". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Tags: Method content maximum variable instance local article maximum knowledge article face code value usage most of that is more steps knowledge points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Technology Docker Xiaomi Shulou Information