本文整理汇总了C#中BitArray.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# BitArray.Clone方法的具体用法?C# BitArray.Clone怎么用?C# BitArray.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitArray
的用法示例。
在下文中一共展示了BitArray.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: runTest
public bool runTest()
{
Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
int iCountErrors = 0;
int iCountTestcases = 0;
String strLoc = "Loc_000oo";
BitArray bitArr1;
BitArray bitArr2;
Boolean[] bolArr1;
Int32 iNumOfElements;
Random rnd1;
try {
do
{
iNumOfElements = 10;
rnd1 = new Random();
strLoc = "Loc_742dsf!";
iCountTestcases++;
bolArr1 = new Boolean[iNumOfElements];
for(int i=0; i<iNumOfElements; i++){
if(rnd1.Next(10)>5)
bolArr1[i] = true;
else
bolArr1[i] = false;
}
bitArr1 = new BitArray(bolArr1);
bitArr2 = (BitArray)bitArr1.Clone();
for(int i=0; i<iNumOfElements; i++){
if(bitArr1[i] != bitArr2[i]){
iCountErrors++;
Console.WriteLine("Err_36tdfg_" + i + "! Wrong value returned, ");
}
}
iCountTestcases++;
for(int i=0; i<iNumOfElements; i++)
bitArr1[i] = !bitArr1[i];
for(int i=0; i<iNumOfElements; i++){
if(bitArr1[i] != !bitArr2[i]){
iCountErrors++;
Console.WriteLine("Err_394t7sg_" + i + "! Wrong value returned, ");
}
}
} while (false);
} catch (Exception exc_general ) {
++iCountErrors;
Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
}
if ( iCountErrors == 0 )
{
Console.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
return true;
}
else
{
Console.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
return false;
}
}
示例2: Ctor_Simple_Method_Tests
public static void Ctor_Simple_Method_Tests()
{
int length = 0;
BitArray bitArray = new BitArray(length);
Assert.NotNull(bitArray.SyncRoot);
Assert.False(bitArray.IsSynchronized);
Assert.False(bitArray.IsReadOnly);
Assert.Equal(bitArray, bitArray.Clone());
}