docs
docs copied to clipboard
Requesting Example of how to use `inheritdoc` with params of a record-type
I was wondering how to do something like this:
/// <summary>
/// the animal concept
/// </summary>
/// <param name="Name">the name</param>
/// <param name="Age">the age</param>
public abstract record Animal(string Name, int Age);
/// <summary>
/// the cat model
/// </summary>
/// <param name="Name">***inheritdoc somehow***</param>
/// <param name="Age">***inheritdoc somehow***</param>
/// <param name="LikesMilk">if this cat likes milk</param>
public record Cat(string Name, int Age, bool LikesMilk)
: Animal(Name, Age);
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
- ID: 60a08067-b91f-3c9a-0569-30d098089990
- Version Independent ID: 33d9f302-a3aa-a165-ec64-a4382feb093e
- Content: Example XML documentation comments
- Content Source: docs/csharp/language-reference/xmldoc/examples.md
- Product: dotnet-csharp
- Technology: csharp-language-reference
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagn
/cc @mikadumont @CyrusNajmabadi
Is there a way to do this?
ahh i think i found it. i just had to think about it differently. i used an example that was meant for method params. but it seems it works the same for the record params
/// <summary>
/// the animal concept
/// </summary>
/// <param name="Name">the name</param>
/// <param name="Age">the age</param>
public abstract record Animal(string Name, int Age);
/// <summary>
/// the cat model
/// </summary>
/// <param name="Name"><inheritdoc cref="Animal" path="/param[@name='Name']"/></param>
/// <param name="Age"><inheritdoc cref="Animal" path="/param[@name='Age']"/></param>
/// <param name="LikesMilk">if this cat likes milk</param>
public record Cat(string Name, int Age, bool LikesMilk)
: Animal(Name, Age);