同样的错误! [英] Same error !!!

查看:83
本文介绍了同样的错误!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Error	1	Cannot implicitly convert type ''void'' to ''double''	C:\Program.cs	56	28	Project-213

using System;
using System.Collections.Generic;
using System.Text;

namespace Wrox.ProCSharp.Delegates
{
   class MathOperations
   {
      public static double MultiplyByTwo(double value)
      {
         return value * 2;
      }

      public static double Square(double value)
      {
         return value * value;
      }
   }


   delegate double DoubleOp(double x);

   class MainEntryPoint
   {
      static void Main()
      {
         DoubleOp[] operations =
            {
               MathOperations.MultiplyByTwo,
               MathOperations.Square
               //new DoubleOp(MathOperations.MultiplyByTwo),
               //new DoubleOp(MathOperations.Square)
            };

         for (int i = 0; i < operations.Length; i++)
         {
            Console.WriteLine("Using operations[{0}]:", i);
            ProcessAndDisplayNumber(operations[i], 2.0);
            ProcessAndDisplayNumber(operations[i], 7.94);
            ProcessAndDisplayNumber(operations[i], 1.414);
            Console.WriteLine();
         }
      }

      static void ProcessAndDisplayNumber(DoubleOp action, double value)
      {
         double result = action(value);
         Console.WriteLine(
            "Value is {0}, result of operation is {1}", value, result);
      }
   }
}

推荐答案

"same error"是什么意思?什么线?我假设"ProcessAndDisplayNumber"的第一行? DobleOp在哪里定义?我看不到任何地方,但它明确地定义为返回void.
What do you mean ''same error'' ? What line ? I assume the first line of ''ProcessAndDisplayNumber'' ? Where is DobleOp defined ? No-where I can see, but it is plainly defined to return void.


看起来您之前已经问过一些问题,并根据一些答案做了更改.如果是这样,请使用相同的旧问题,并使用添加评论"功能回覆该答复,引起您的关注,告诉他们您的观察结果.
Looks like you have asked something earlier and did the changes according to some answer. If so, use the same old question and use ''Add Comment'' feature to respond back to that reply raising your concern, telling them your observation.


这篇关于同样的错误!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆