我有一个1000循环的“for循环”,其输出为2 * 2矩阵。所以,我的问题是“如何将所有迭代的输出存储为对角线(或块对角线)矩阵?”
public interface IA
{
int X { get; set; }
}
public interface IB
{
int X { get; set; }
}
public class C : IA, IB
{
public int X { get; set; }
int IB.X { get; set; }
}
public PropertyInfo GetProperty<TClass, TProperty>(Expression<Func<TClass, TProperty>> getProperty)
{
return (PropertyInfo)((MemberExpression)getProperty.Body).Member;
}
[Test]
public void Check()
{
var aProperty = GetProperty((IA x) => x.X);
var bProperty = GetProperty((IB x) => x.X);
var cPropertyA = GetProperty((C x) => x.X);
var cPropertyB = GetProperty((C x) => ((IB)x).X);
CompareProperties(cPropertyA, aProperty); // True
CompareProperties(cPropertyA, bProperty); // False
CompareProperties(cPropertyB, aProperty); // False
CompareProperties(cPropertyB, bProperty); // True
}
private bool CompareProperties(PropertyInfo classProperty, PropertyInfo interfaceProperty)
{
// TODO implement
}