Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Different versions of GetFirstDirectoryFrom

View GetFirstDirectoryFrom1.cs
1 2 3 4 5 6 7 8 9 10
public DirectoryInfo GetFirstDirectoryFrom(params string[] list)
{
foreach (var item in list)
{
var directory = new DirectoryInfo(item);
if (directory.Exists)
return directory;
}
return null;
}
View GetFirstDirectoryFrom1.cs
1 2 3 4
public DirectoryInfo GetFirstDirectoryFrom(params string[] list)
{
return list.Select(l => new DirectoryInfo(l)).Where(d => d.Exists).FirstOrDefault();
}
View GetFirstDirectoryFrom1.cs
1 2 3 4
public DirectoryInfo GetFirstDirectoryFrom(params string[] list)
{
return list.Select(l => new DirectoryInfo(l)).SkipWhile(d => !d.Exists).FirstOrDefault();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.