How to do oneliner code with loop and condition?

How will i make this an oneliner code?

int result = 0;
if (directory.Files.Count() > 0)
{
    foreach (var file in directory.Files)
    {
        result += file.FileCommits.Count() > 0 ? file.FileCommits.Last().LinesOfCode : 0;
    }
}
return result;


Source: syntax

Leave a Reply