本文整理汇总了C#中DoubleVector.LastIndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleVector.LastIndexOf方法的具体用法?C# DoubleVector.LastIndexOf怎么用?C# DoubleVector.LastIndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleVector
的用法示例。
在下文中一共展示了DoubleVector.LastIndexOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
{
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");
} catch (ArgumentNullException) {
}
{
// Collection initializer test, requires C# 3.0
// myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 };
}
// IndexOf() test
for (int i=0; i<collectionSize; i++) {
if (vect.IndexOf(i*10.1) != i)
throw new Exception("IndexOf test " + i + " failed");
}
if (vect.IndexOf(200.1) != -1)
throw new Exception("IndexOf non-existent test failed");
if (dv.IndexOf(33.3) != 3)
throw new Exception("IndexOf position test failed");
// LastIndexOf() test
for (int i=0; i<collectionSize; i++) {
if (vect.LastIndexOf(i*10.1) != i)
throw new Exception("LastIndexOf test " + i + " failed");
}
if (vect.LastIndexOf(200.1) != -1)
throw new Exception("LastIndexOf non-existent test failed");
if (dv.LastIndexOf(33.3) != 6)
throw new Exception("LastIndexOf position test failed");
// Copy constructor test
DoubleVector dvCopy = new DoubleVector(dv);
for (int i=0; i<doubleArray.Length; i++) {
if (doubleArray[i] != dvCopy[i])
throw new Exception("Copy constructor failed, index:" + i);
}
}
{
// Repeat() test
try {
myDoubleVector = DoubleVector.Repeat(77.7, -1);
throw new Exception("Repeat negative count test failed");
} catch (ArgumentOutOfRangeException) {
}
DoubleVector dv = DoubleVector.Repeat(77.7, 5);
if (dv.Count != 5)
throw new Exception("Repeat count test failed");
// Also tests enumerator
{
System.Collections.IEnumerator myEnumerator = dv.GetEnumerator();
while ( myEnumerator.MoveNext() ) {
if ((double)myEnumerator.Current != 77.7)
throw new Exception("Repeat (1) test failed");
}