Hi,

I'm trying to execute this but it says "cannot implicitly convert int to bool".

for (i = 0; i < k; i++) { 
         for (j = 0; j < m; j++) {
            c[i][j] = counts[i] ? c1[i][j] / counts[i] : c1[i][j];
         }
      }

Is there anyway that I can write it as simple as possible without any complications?

Thanks

Recommended Answers

All 2 Replies

it's line 3 that is the problem, the part right after the equal sign. counts is not a boolean value but you are treating it as one. What condition are you trying to test for?

This is a common bad habit C/C++ programmers develop :)

Suspect you want to test for zero, rewrite line 3 like this:

c[i][j] = counts[i] == 0 ? c1[i][j] / counts[i] : c1[i][j];

As Momerath already pointed out, you cannot use things like while(0) in C#.
I love C# for it!!! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.