c# - "No argument given" when inheriting from a class
问题描述
Unity uses an older version of C#, so we don't have a builtin Tuple
class. I have the following definition that I basically copied from somewhere on the internet, unfortunately I don't remember where:
public class Tuple<T1, T2>
{
public T1 First { get; private set; }
public T2 Second { get; private set; }
internal Tuple(T1 first, T2 second)
{
First = first;
Second = second;
}
}
public static class Tuple
{
public static Tuple<T1, T2> New<T1, T2>(T1 first, T2 second)
{
var tuple = new Tuple<T1, T2>(first, second);
return tuple;
}
}
That's fine, it works for my needs.
However now I have a script which needs to refer to a specific Tuple type many times, and I want to 'alias' that type:
public class RequiredField : Tuple<Type, MonoBehaviour>{}
I want RequiredField
to basically be an alias for Tuple<Type, MonoBehaviour>
.
This is giving me an error:
There is no argument given that corresponds to the required formal parameter 'first' of 'Tuple.Tuple(Type, MonoBehaviour)' (CS7036) [Assembly-CSharp]
I sort of know the bare-minimum amount of C# needed to do basic Unity programming ... unfortunately that means I am ill-equipped to debug errors like this.
Can anyone point in the direction of how to fix this?
解决方案
推荐阅读
- python - 如何使用 selenium 和 Python 检索类中的值
- selenium - 机器人框架以不同用户身份运行
- html - 带有来自底层 div 的背景图像的文本
- python - COCO .json 文件的注释中包含奇怪的分段值,如何转换这些值?
- permissions - 如何在 discord.py 中编辑角色权限?
- javascript - 如何在我的第一页 HTML 上限制我的 Javascript 代码?
- amazon-web-services - MS Graph Webhook 只能调用公共 API 吗?
- json - 如何保存 JSON 对象并在另一个请求中使用它?
- reactjs - 无法使用 'useStoreState 在 react easy-peasy 中访问状态
- python - Django - 为什么我在认证后没有登录?