三、c#基础数据类型和函数
如果用中学时期数学函数的概念来理解类 y = f(x)
修饰符 返回值类型 函数名称 (参数类型 参数名){ 逻辑算法 }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CsharpData
{
class Program
{
static void Main(string[] args)
{
int appleCount1 = 1314;
float applePrice1 = 2.5f;
int orangeCount1 = 520;
float orangePrice1 = 3.1f;
float totlePrice = GetTotlePrice(appleCount1, applePrice1, orangeCount1, orangePrice1);
Console.WriteLine("水果的总价格是"+totlePrice);
}
public static float GetTotlePrice(int appleCount, float applePrice,int orangeCount, float orangePrice)
{
return appleCount * applePrice + orangeCount * orangePrice;
}
}
}