Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 623 Bytes

File metadata and controls

25 lines (18 loc) · 623 Bytes

GCop 533

"Choose return type of IEnumerable<\{entityType}> to imply that it's not modifiable."

Rule description

When your code only needs to read data and return that, use IEnumerable type rather than List. IEnumerable<T> is nice to use when you want to represent sequence of items, that you can iterate over, but you don't want to allow modifications (Add, Delete etc).

Example

public List<Setting> GetSettings()
{
    // ... code that only return Settings
}

should be 🡻

public IEnumerable<Setting> GetSettings()
{
    // ... code that only return Settings
}