繁体   English   中英

为什么有时我需要在 C# 中调用构造函数/函数时显式指定泛型类型?

[英]Why sometime I need to explicitly specific the generic type when calling constructor/function in C#?

在此处输入图像描述

参考上图,我们可以看到AbpAsyncDeterminiationInterceptor必须具有与其构造函数中提供的相同的泛型类型。 假设它应该被自动解释,而不是明确指定类似new AbpAsyncDeterminiationInterceptor<BlueprintInterceptor>(new BlueprintInterceptor());

奇怪的是,有时当我调用一个函数时,我不需要指定泛型类型,而函数可以从参数类型中揭示返回类型。

提前致谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM