本文介绍了什么是具体实施?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在StackOverflow和其他地方看到了很多关于具体实现的文章.在摆弄WCF的同时,我走了一条路

I saw lot of posts in StackOverflow and elsewhere talking about concrete implementation. While fiddling with WCF i came through the line

任何人都可以解释什么是具体实现吗?

Can anyone explain what Concrete Implementation is?

推荐答案

它是某种抽象的实现(抽象类,接口).请注意,您只能实例化具体类的对象.

It is implementation of something abstract (abstract class, interface).Note that you can instantiate only objects of concrete classes.

例如,如果您有:

abstract class AbstractClass
{
    .......
   // Here you have some abstract methods 
}

class ConcreteClass : AbstractClass
{
.......
}

对于WCF,它想说的是,尽管允许更好地标记带有ServiceContract属性的类,但最好将其放在单独的接口上,并在带有ServiceBehavior属性标记的具体类中实现该接口.

In case of WCF it wants to say that although it is allowed to mark classes with ServiceContract attribute better to have it on separate Interface and implement that interface in concrete class marked with ServiceBehavior attribute.

喜欢这个:

[ServiceContract(Namespace = "MyNamespaceName")]
interface IMyInterface
{
    [OperationContract]
    int SomeMethod(.....);

   ......    
   ......    
}

[ServiceBehavior(......)]
public class SomethingConcrete : IMyInterface
{
    // implementation of SomeMethod
}

这篇关于什么是具体实施?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 07:11