What is an empty interface used for

后端 未结 12 2701
醉话见心
醉话见心 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:14

    They're called "Mark Interfaces" and are meant to signal instances of the marked classes.

    For example... in C++ is a common practice to mark as "ICollectible" objects so they can be stored in generic non typed collections.

    So like someone over says, they're to signal some object supported behavior, like ability to be collected, serialized, etc.

提交回复
热议问题