我学习,您监督之Chart06
Posted ONEZERO
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了我学习,您监督之Chart06相关的知识,希望对你有一定的参考价值。
这是课程6中更改后的,原文显示的有些看不懂
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using static System.Console;
//using static System.Convert;
namespace Ch06Ex05
{
class Program
{
delegate double ProcessDelegate(double param1, double param2);
/******
原文是:
static double Multiply(double param1, double param2) => param1 * param2;
static double Divide(double param1, double param2) => param1 / param2;
注:这个编译报错VS2013
*********/
修改后的是:
static double Multiply(double param1, double param2)
{
return param1 * param2;
}
static double Divide(double param1, double param2)
{
return param1 / param2;
}
这个正常,请问是什么原因呢?
static void Main(string[] args)
{
ProcessDelegate process;
Console.WriteLine("Enter 2 numbers separated with a comma:");
string input = Console.ReadLine();
int commaPos = input.IndexOf(‘,‘);
double param1 = Convert.ToDouble(input.Substring(0, commaPos));
double param2 = Convert.ToDouble(input.Substring(commaPos + 1,
input.Length - commaPos - 1));
Console.WriteLine("Enter M to multiply or D to divide:");
input = Console.ReadLine();
if (input == "M")
process = new ProcessDelegate(Multiply);
else
process = new ProcessDelegate(Divide);
Console.WriteLine("Result: {0}", process(param1, param2));
Console.ReadKey();
}
}
}
以上是关于我学习,您监督之Chart06的主要内容,如果未能解决你的问题,请参考以下文章