【发布时间】:2010-10-26 11:17:54
【问题描述】:
问题:我有一些用于 pgp 加密的代码: http://blogs.microsoft.co.il/blogs/kim/archive/2009/01/23/pgp-zip-encrypted-files-with-c.aspx
它有以下方法,使用一些 LINQ。 我仍在使用 .NET 2.0,无法切换到更高版本,但...
如何用普通代码替换这个表达式? 我不太了解 Linq,我猜它做了一些排序?
private PgpSecretKey GetFirstSecretKey(PgpSecretKeyRingBundle secretKeyRingBundle)
{
foreach (PgpSecretKeyRing kRing in secretKeyRingBundle.GetKeyRings())
{
PgpSecretKey key = kRing.GetSecretKeys()
.Cast<PgpSecretKey>()
.Where(k => k.IsSigningKey)
.FirstOrDefault();
if (key != null)
return key;
}
return null;
}
【问题讨论】: