/* Simple 256 x 3 array with data of type string containing reps of numerical Trying to write to console converted value but filter only one of the inner loop's cycles. Why can't the use of "if(rs = 0)" do the filtering? */ using namespace System; using namespace System::IO; using namespace System::Text; /* array of 256 x 3 */ void PrintValues(Array^ myArr); int main() { array<String^, 2>^testArray = gcnew array<String^,2>(256,3); /* zero (as string) array ... */ for (int aa=testArray->GetLowerBound(0);aa<=testArray->GetUpperBound(0);aa++) for (int ab=testArray->GetLowerBound(1);ab<=testArray->GetUpperBound(1);ab++) { testArray->SetValue("0",aa,ab); } /* comment this next three lines to avoid the print out of the array content */ PrintValues(testArray); Console::WriteLine(" "); Console::WriteLine(" "); /* add some string content to the zeroed table */ testArray->SetValue("555",23,1); testArray->SetValue("129",128,2); testArray->SetValue("141",45,0); /* output the tabular data in an admittedly odd fashion (wait ... there's a point here) */ for (int aa=testArray->GetLowerBound(0);aa<=testArray->GetUpperBound(0);aa++) for (int ab=testArray->GetLowerBound(1);ab<=testArray->GetUpperBound(1);ab++) { if (Convert::ToInt32(testArray[aa,0])>0) /* this will return three runs at that value located @ testArray[45,0] all of which are 141 */ Console::WriteLine("using GetValue: {0}", testArray->GetValue(aa,0)); } //PrintValues(testArray); /* Now, here's the "filter" I'd like to add to this for loop; the reason for this question -> seems like a no brainer in an "if-then-else sense". But no! */ //for (int aa=testArray->GetLowerBound(0);aa<=testArray->GetUpperBound(0);aa++) // for (int ab=testArray->GetLowerBound(1);ab<=testArray->GetUpperBound(1);ab++) // { // if (Convert::ToInt32(testArray[aa,0])>0) // /* this will never return ... */ // if(ab=0) // { // Console::WriteLine("using GetValue: {0}", testArray->GetValue(aa,0)); // } // } } void PrintValues( Array^ myArr ) { System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); int i = 0; int cols = myArr->GetLength( myArr->Rank - 1 ); while ( myEnumerator->MoveNext() ) { if ( i < cols ) { i++; } else { Console::WriteLine(); i = 1; } Console::Write( "\t{0}", myEnumerator->Current ); } }
RedDK wrote:if(ab=0)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)