What is an empty interface used for

后端 未结 12 2715
醉话见心
醉话见心 2020-12-13 17:18

I am looking at nServiceBus and came over this interface

namespace NServiceBus
{
    public interface IMessage
    {
    }
}

What is the us

12条回答
  •  佛祖请我去吃肉
    2020-12-13 18:02

    Empty interfaces are used to document that the classes that implement a given interface have a certain behaviour

    For example in java the Cloneable interface in Java is an empty interface. When a class implements the Cloneable interface you know that you can call run the clone() on it.

提交回复
热议问题