Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1063113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:44:08+00:00 2026-05-16T18:44:08+00:00

Say I have this constructor: /// <summary> /// Example comment. /// </summary> public SftpConnection(string

  • 0

Say I have this constructor:

/// <summary>
/// Example comment.
/// </summary>
public SftpConnection(string host, string username, 
    string password, int port) {...}

which has these overloads:

public SftpConnection(string host, string username, string password) 
    : this(host, username, password, 22) { }

public SftpConnection(string host, string username, int port) 
    : this(host, username, "", port) { }

public SftpConnection(string host, string username) 
    : this(host, username, "", 22) { }

and in reality, the XML comment is pretty large, with param, example and exception elements and so on.

Is there some way to add a special XML comment one-liner to the overloads, such that they use the exact same comments so that I don’t need to copy-paste the whole, enormous original comments?

I’m thinking something like: <use cref="SftpConnection(string,string,string,int)" /> which doesn’t work of course.

I am aware of the include element, but I get the impression it reads the comments from an XML file instead, which I don’t want – I want the comment to still be visible in the code, but only once.

Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:44:09+00:00Added an answer on May 16, 2026 at 6:44 pm

    You can’t really do this. I find it annoying too.

    However, you can alleviate the problem by using default parameter values instead of lots of overloads. Instead of:

    public SftpConnection(string host, string username, string password, int port)
    public SftpConnection(string host, string username, string password)
    public SftpConnection(string host, string username, int port)
    public SftpConnection(string host, string username)
    

    You can have just a single one:

    public SftpConnection(string host, string username, string password = "",
                          int port = 22)
    

    This has multiple advantages:

    • Need only one XML comment. The whole point of my answer. ☺

    • Users of Visual Studio can instantly see that the default value for port is 22. With the overloads, this is not obvious; you have to specifically mention it in the documentation.

    • You indirectly encourage client code to become more readable by encouraging the use of named parameters (e.g. port: 2222 instead of just 2222, which is less clear).

    And the greatest part about this is that using default values does not remove the ability to still have several overloads if you need them. Typical examples where you want overloads with default values might be something like…

    ReadFrom(string filename, ReaderOptions options = null)
    ReadFrom(Stream stream, ReaderOptions options = null)
    ReadFrom(byte[] rawData, ReaderOptions options = null)
    

    In these cases, I would argue the XML comments should actually be different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 529k
  • Answers 529k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This one clears it up pretty nicely: http://www.thismuchiknow.co.uk/?p=71 May 16, 2026 at 11:12 pm
  • Editorial Team
    Editorial Team added an answer Is that so hard? <?php for($i=1;$i<10;$i++) { for($j=1;$j<=$i;$j++) echo $j;… May 16, 2026 at 11:12 pm
  • Editorial Team
    Editorial Team added an answer class ListNode { public ListNode next; public Object data; public… May 16, 2026 at 11:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Lets say have this immutable record type: public class Record { public Record(int x,
Say I have a component like this public class MyComponent { public MyComponent(string name)
Lets say we have this code that runs in the constructor: Dim initVectorBytes As
Lets say I have business class: public class Foo { public int Prop1 {get;set;}
Let's say I have the following two classes: public class Person { public string
Can Unity automatically resolve IEnumerable<T> ? Let's say I have a class with this
Let's assume I have a c++ class that have properly implemented a copy constructor
let's say i have a class A and a class B. B is used
I have some object, say son , which I'd like to inherit from another
String processing in C# and VB.NET is easy for me, but understanding how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.