In Java, it is a common practice to redefine JavaDoc comments in interfaces extending other interfaces:
interface Foo {
/**
* Basic getGadget information
*/
String getGadget();
}
interface Bar extends Foo {
/**
* More specific getGadget description, in context of Bar
*/
@Override
String getGadget();
}
Is there a way to achieve similar goal in C#?
With a direct translation:
interface IFoo
{
/// <summary>
/// Basic GetGadget information
/// </summary>
string GetGadget();
}
interface IBar : IFoo
{
/// <summary>
/// More specific GetGadget description, in context of IBar
/// </summary>
string GetGadget();
}
the compiler warns on member hiding:
IFoo.cs(16, 16): [CS0108] 'IBar.GetGadget()' hides inherited member 'IFoo.GetGadget()'. Use the new keyword if hiding was intended.
Edit
- My goal is ONLY to have a more specific comment.
- I still want to call
GetGadget
viaIFoo
instance and get the method fromIBar
new
allows following implementation if IBar, which I want to avoid (conceptually, there is only one method)
class C : IBar
{
string IFoo.GetGadget()
{
throw new System.NotImplementedException();
}
string IBar.GetGadget()
{
throw new System.NotImplementedException();
}
}