Skip to main content

Member names cannot be the same as their enclosing type

In This Article

CodeRush Classic shows the Member names cannot be the same as their enclosing type code issue if a member has the same name as its enclosing type.

Note

The code issue is not available in Visual Basic, because Visual Basic allows you to give equal names to a member and its enclosing type.

#Fix

Rename the member.

#Purpose

Highlights the member declarations, which would cause the Member names cannot be the same as their enclosing type compilation error.

#Example

public class MyData
{
    public object MyData { get; set; }
}

Fix:

public class MyData
{
    public object Data { get; set; }
}