SkyeBoniwell
SkyeBoniwell

Reputation: 7092

cannot access property within the same class

I'm having trouble understanding why a part of my code can't resolve another part.

I have this class that contains two properties. The second property relies on the first, but it keeps throwing this error:

cannot resolve symbol 'yearlyEmployees'

public class Financials
{

    public static IEnumerable<SalaryEntity> yearlyEmployees = FactoryManagement(12345);


    //cannot resolve symbol 'yearlyEmployees'
    public static IEnumerable<CompanyEntity> YearlyGroup(IList<yearlyEmployees> allExempt)
    {

    }

}

I'm sure there's an easy answer, but I just can't find it.

Thanks!

Upvotes: 1

Views: 379

Answers (3)

Emmett Lin
Emmett Lin

Reputation: 666

yearlyEmployees is a variable name, not a class name. Try:

public static IEnumerable<CompanyEntity> YearlyGroup(IList<SalaryEntity> allExempt)

Upvotes: 11

Gilad Green
Gilad Green

Reputation: 37299

That is because you don't have a type of yearlyEmplyee - that is your variable.

Instead:

public static IEnumerable<CompanyEntity> YearlyGroup(IList<SalaryEntity> allExempt)
{ }

And then just pass a collection of SalaryEntity to the function. If you always want to process only yearlyEmployees (which I don't think is the case but not sure) then just call it from within the method `Financials.yearlyEmployees'.

Upvotes: 1

Carlos Lemes
Carlos Lemes

Reputation: 11

You must use the type SalaryEntity as item for your list.

public static IEnumerable<CompanyEntity> YearlyGroup(IList<SalaryEntity> allExempt) {}

Upvotes: 1

Related Questions