c# - 如何在接口中调用带有主体的方法
问题描述
我有一个接口定义为:
interface IProperty<T>
{
public T Value { get; set; }
public T GetTheValue()
{
return (T)(Value);
}
}
一个实现为:
class Animal : IProperty<string>
{
public string Value { get; set; }
}
用作:
var camel = new Animal { Value = "Camel" };
类的实例如何Animal
访问接口GetTheValue()
中的方法IProperty<T>
?(IntelliSense 中没有显示任何内容)
如果不能,接口中带有主体的方法的目的是什么?
解决方案
推荐阅读
- mysql - 意外的 Lambda 行为
- laravel - Laravel 5.6 - 胖模型,瘦控制器
- math - 沿着曲线创建螺旋线
- node.js - 为什么 node.js 不异步处理这两个函数/方法?
- r - 如何从 EcosimR 输出的摘要中提取 SES
- alibaba-cloud - 在同一个 ECS 实例上运行 2 个网站 阿里云
- symfony - 带有查询过滤器的 Symfony ModelListType 表单
- css - 删除字体中不需要的空间 - css
- python - 订阅 Gazebo 模拟世界中 sdf 模型的子链接
- regex - 正则表达式匹配字符串 where '.' 恰好出现 x 次