views:

68

answers:

2

When defining properties I like to do just before property declaration, something like this

private IList<SomeType> _myList;
public IEnumerable<SomeType> MyList
{
   get { return _myList;}
}

But if I place ///<summary> tag on the property, I lose the benefit of declaring the backing fields like this, it is not readable any more. If I place it before backing field, comments do not show in the IDE. Is there a way to put summary tag before backing field and have it show up in IDE (VS2008)?

+6  A: 

The /// <summary> tag has to be placed just before the element it is describing.

You can try and put the field just after the property:

/// <summary>
public IEnumerable<SomeType> MyList
{
  get { return _myList;}
}
private IList<SomeType> _myList;

If the backing field is not essential (only used the same way as your example), you can simply use automatic properties:

/// <summary>
public IEnumerable<SomeType> MyList
{
  get;
}
Oded
Just as I thought, just wanted to make sure there was not some hidden gem.
epitka
A: 

With automatic properties, this has become less of a concern to me; I have taken to putting any explicit backing fields that I need in a group separated from the properties.

Chris Shaffer