草庐IT

A_INTERFACE

全部标签

c# - 为什么在 C# 接口(interface)名称前加上 “I”

此命名约定背后的基本原理是什么?我没有看到任何好处。额外的前缀只会污染API。我的想法与Konrad的一致response与此相关question;选择answer其中大部分是我在这里要求的。 最佳答案 它完全相反,命名约定清楚地标识了一个接口(interface)。例如,如果您有:publicclassDog:IPet,IMammal{....仅通过阅读,我就可以有把握地假设IPet和IMammal可能是接口(interface)。.NETCLR允许单类继承。所以,如果我有一个基类……我只能从它继承一个类。让我们将IPet接口(i

c# - 获取类实现的泛型接口(interface)的类型参数

我有一个通用接口(interface),比如IGeneric。对于给定的类型,我想找到一个类通过IGeneric实现的泛型参数。这个例子更清楚:ClassMyClass:IGeneric,IGeneric,IDontWantThis{...}Typet=typeof(MyClass);Type[]typeArgs=GetTypeArgsOfInterfacesOf(t);//Atthispoint,typeArgsmustbeequalto{typeof(Employee),typeof(Company)}GetTypeArgsOfInterfacesOf(Typet)的实现是什么?注

c# - 获取类实现的泛型接口(interface)的类型参数

我有一个通用接口(interface),比如IGeneric。对于给定的类型,我想找到一个类通过IGeneric实现的泛型参数。这个例子更清楚:ClassMyClass:IGeneric,IGeneric,IDontWantThis{...}Typet=typeof(MyClass);Type[]typeArgs=GetTypeArgsOfInterfacesOf(t);//Atthispoint,typeArgsmustbeequalto{typeof(Employee),typeof(Company)}GetTypeArgsOfInterfacesOf(Typet)的实现是什么?注

C#接口(interface)方法歧义

考虑以下示例:interfaceIBase1{intPercentage{get;set;}}interfaceIBase2{intPercentage{get;set;}}interfaceIAllYourBase:IBase1,IBase2{}classAllYourBase:IAllYourBase{intpercentage;intPercentage{get{returnpercentage;}set{percentage=value;}}}voidFoo(){IAllYourBaseiayb=newAllYourBase();intpercentage=iayb.Perce

C#接口(interface)方法歧义

考虑以下示例:interfaceIBase1{intPercentage{get;set;}}interfaceIBase2{intPercentage{get;set;}}interfaceIAllYourBase:IBase1,IBase2{}classAllYourBase:IAllYourBase{intpercentage;intPercentage{get{returnpercentage;}set{percentage=value;}}}voidFoo(){IAllYourBaseiayb=newAllYourBase();intpercentage=iayb.Perce

c# - 异常(exception)是 : InvalidOperationException - The current type, 是一个接口(interface),无法构造。您是否缺少类型映射?

在我的Bootstrap中:namespaceConduit.Mam.ClientServices.Common.Initizliaer{publicstaticclassInitializer{privatestaticboolisInitialize;privatestaticreadonlyobjectLockObj=newobject();privatestaticIUnityContainerdefaultContainer=newUnityContainer();staticInitializer(){Initialize();}publicstaticvoidInitia

c# - 异常(exception)是 : InvalidOperationException - The current type, 是一个接口(interface),无法构造。您是否缺少类型映射?

在我的Bootstrap中:namespaceConduit.Mam.ClientServices.Common.Initizliaer{publicstaticclassInitializer{privatestaticboolisInitialize;privatestaticreadonlyobjectLockObj=newobject();privatestaticIUnityContainerdefaultContainer=newUnityContainer();staticInitializer(){Initialize();}publicstaticvoidInitia

c# - 使 Entity Framework 实现一个接口(interface)

我想将IoC与EntityFramework和Ninject结合使用。我认为我需要生成的实体类来实现接口(interface)ICRUD。有一个walkthrough这显示了如何强制EntityFramework实现接口(interface)。我按照说明进行操作,我的EntityObjectCodeGenerator.cs文件确实显示了“ICrud”,但没有实现接口(interface)。正如文章所说,我没有在EntityObjectCodeGenerator.tt下看到任何子类。我收到错误'BugnetMvc.Models.BugNetEntities'doesnotimplemen

c# - 使 Entity Framework 实现一个接口(interface)

我想将IoC与EntityFramework和Ninject结合使用。我认为我需要生成的实体类来实现接口(interface)ICRUD。有一个walkthrough这显示了如何强制EntityFramework实现接口(interface)。我按照说明进行操作,我的EntityObjectCodeGenerator.cs文件确实显示了“ICrud”,但没有实现接口(interface)。正如文章所说,我没有在EntityObjectCodeGenerator.tt下看到任何子类。我收到错误'BugnetMvc.Models.BugNetEntities'doesnotimplemen

c# - C# .NET 中最流行/最常用/最重要的接口(interface)?

除了IEnumerable、IComparable,C#.NET中还有哪些“重要”(或经常使用)的接口(interface)是我需要了解的? 最佳答案 Samequestion从那里复制粘贴:IEnumerable(和IEnumerable):用于foreach和LINQIDisposable:用于需要清理的资源,配合using使用IQueryable:允许您针对可查询的数据源执行请求。INotifyPropertyChange:用于数据绑定(bind)到WPF、winforms和silverlight中的UI类IComparabl