About Method Of C#
2018-06-07 本文已影响0人
何三岁_
About how to use method of Csharp.
For illustrate,The code is as follows:
using System;
namespace UseMethod
{
class program
{
static void Main (string[] args)
{
double GetHeight;
double GetWidth;
GetHeight = Convert.ToDouble(Console.ReadLine());
GetWidth = Convert.ToDouble(Console.ReadLine());
GetHeight = Convert.ToDouble(GetHeight);
GetWidth = Convert.ToDouble(GetWidth);
//this is simple call method demo.
Console.WriteLine(RectangleArea(GetHeight,GetWidth));
Console.ReadKey();
}
static double RectangleArea(double height, double width)
{
return Convert.ToDouble(height*width);
}
}
}
In this segments code,Involve console get to Double Type.Please refer to details: https://blog.csdn.net/yushaopu/article/details/52065833
We could saw,If you want declare a Method,Must include acceess modifier(static public private)、returned value(short char int double long void )、method name、parameter list(int double short ...)and method body,As follows:
<Access Specifier> <Return Type> <Method Name>(Parameter List)
{
Method Body
}