英文:
How can I inherit the docstring of the class in my constructor
问题
/// <summary>
/// 在这种情况下,用户是新加入群组的,但可能以前就存在。
/// </summary>
class NewUserData {
public User user;
// 更多数据字段在这里...
public NewUserData(){
// 在这里创建测试数据...
}
}
var data = new NewUserData();
在IDE(Visual Studio)中悬停在 NewUserData
上不会显示文档字符串。是否有办法让它在不将文档字符串移到构造函数下面的情况下显示?
<details>
<summary>英文:</summary>
I have a class to generate test data that I have documented with a docstring.
```csharp
/// <summary>
/// In this scenario the user is new to the group, but may have existed from before.
/// </summary>
class NewUserData {
public User user;
// More data fields here ...
public NewUserData(){
// Creating test data here ...
}
}
The class is used in a unit test like this:
var data = new NewUserData();
Hovering over NewUserData
doesn't show me the docstring in IDE (Visual Studio). Is there a way to make this happen without moving the docstring down to the constructor?
答案1
得分: 1
"Found out one can achieve this with the inheritdoc tag and specify the class name as cref.
/// <inheritdoc cref="NewUserData"/>
var data = new NewUserData();
```"
<details>
<summary>英文:</summary>
Found out one can achieve this with the inheritdoc tag and specify the class name as cref.
```csharp
/// <inheritdoc cref="NewUserData"/>
var data = new NewUserData();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论