如何删除错误? [英] How do I remove error?
本文介绍了如何删除错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用整数和方法使用double声明了一个委托,我在main方法上得到一个错误,我在那里实例化了委托对象。我该解决这个问题吗?
我尝试过:
I declared a delegate using integer and methods using double and I get an error on main method where I instantiated the delegate object.how do I fix this?
What I have tried:
class Program
{
//creating a delegate Converter
delegate int Converter(int value);
//method to calculate Fahrenheit to Celsius
static double ToCel(int fah)
{
return (fah - 32) / 1.8;
}
//method to callculate Celsius to Fahrenheit
static double ToFah(int celsius)
{
return celsius * 1.8 + 32;
}
//the method to calculate Celsius to Kelvin
static double ToKel(int celsius2)
{
return celsius2 + 273.15;
}
//the method to calculate celsius to Rankine
static double ToRank(int celsius3)
{
return (celsius3 + 273.15) * 1.8;
}
static void Main(string[] args)
{
//institiating object for delegate
Converter process = ToCel;
Converter process1 = ToCel;
Converter process2 = ToKel;
Converter process3 = ToKel;
}
}
推荐答案
更改
Change
delegate int Converter(int value);
to
to
delegate double Converter(int value);
委托的签名必须与您要表示的方法的签名相匹配。
The signature of the delegate has to match the signature of the method(s) you intend to represent.
更正
correction
delegate double Converter(int value);
这篇关于如何删除错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文