本文整理汇总了C#中DoubleVector.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleVector.Contains方法的具体用法?C# DoubleVector.Contains怎么用?C# DoubleVector.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleVector
的用法示例。
在下文中一共展示了DoubleVector.Contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
throw new Exception("CopyTo (4) test failed");
} catch (ArgumentException) {
}
}
{
StructVector inputvector = new StructVector();
int arrayLen = 10;
for (int i=0; i<arrayLen; i++) {
inputvector.Add(new Struct(i/10.0));
}
Struct[] outputarray = new Struct[arrayLen];
inputvector.CopyTo(outputarray);
for(int i=0; i<arrayLen; i++) {
if (outputarray[i].num != inputvector[i].num)
throw new Exception("CopyTo (6) test failed, i:" + i);
}
foreach (Struct s in inputvector) {
s.num += 20.0;
}
for(int i=0; i<arrayLen; i++) {
if (outputarray[i].num + 20.0 != inputvector[i].num )
throw new Exception("CopyTo (7) test failed (only a shallow copy was made), i:" + i);
}
}
{
try {
vect.CopyTo(null);
throw new Exception("CopyTo (8) test failed");
} catch (ArgumentNullException) {
}
}
// Contains() test
if (!vect.Contains(0*10.1))
throw new Exception("Contains test 1 failed");
if (!vect.Contains(10*10.1))
throw new Exception("Contains test 2 failed");
if (!vect.Contains(19*10.1))
throw new Exception("Contains test 3 failed");
if (vect.Contains(20*10.1))
throw new Exception("Contains test 4 failed");
{
// ICollection constructor
double[] doubleArray = new double[] { 0.0, 11.1, 22.2, 33.3, 44.4, 55.5, 33.3 };
DoubleVector dv = new DoubleVector(doubleArray);
if (doubleArray.Length != dv.Count)
throw new Exception("ICollection constructor length check failed: " + doubleArray.Length + "-" + dv.Count);
for (int i=0; i<doubleArray.Length; i++) {
if (doubleArray[i] != dv[i])
throw new Exception("ICollection constructor failed, index:" + i);
}
{
Struct[] structArray = new Struct[] { new Struct(0.0), new Struct(11.1), new Struct(22.2), new Struct(33.3) };
StructVector sv = new StructVector(structArray);
for (int i=0; i<structArray.Length; i++) {
structArray[i].num += 200.0;
}
for (int i=0; i<structArray.Length; i++) {
if (structArray[i].num != sv[i].num + 200.0)
throw new Exception("ICollection constructor not a deep copy, index:" + i);
}
}
try {
new DoubleVector((System.Collections.ICollection)null);
throw new Exception("ICollection constructor null test failed");