What is an empty interface used for

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

    In Java, empty interfaces were usually used for "tagging" classes - these days annotations would normally be used.

    It's just a way of adding a bit of metadata to a class saying, "This class is suitable for kind of use" even when no common members will be involved.

提交回复
热议问题