开发者

Failed to get MaxValue from data

开发者 https://www.devze.com 2023-03-01 03:42 出处:网络
well, maybe this is a simple question for you, but for a newbie like me it\'s kinda confusing okey, I try to get a maximum value from an array, here\'s my code

well, maybe this is a simple question for you, but for a newbie like me it's kinda confusing

okey, I try to get a maximum value from an array, here's my code

int sample = input.GetLength(0);
double maxValue = double.MinValue;  

for (int i = 0; i < sample; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    if (value[i][j] > maxValue)
                        maxValue = value[i][j];
                }
            }
    SetText(textBox1, maxValue.ToString());

And here is my number

10192 20351 30473 40499 50449 60234 
10192 20207 30206 40203 50205 60226 
10192 20252 30312 40376 50334 60252 

but when I showed it, the number is wrong. or weird for me. instead like 60234

it showed 1.0612312312E-308 something like that.

is it my code wrong or there's something missing?

thanks for any help anyway.

EDIT

VALUE is

the number with jagged array indexing

so it's based on row and column like

value[0][0] for 1st开发者_运维问答 row and 1st column so on.

what I want to do is search in all indexed array and show the maximumvalue.


I should do this:

double maxValue = double.MinValue;
for (int i = 0; i < value.GetLength(0); i++)
{
    for (int j = 0; j < value.GetLength(1); j++)
    {
        if (value[i][j] > maxValue)
        maxValue = value[i][j];
    }
}
SetText(textBox1, maxValue.ToString());
0

精彩评论

暂无评论...
验证码 换一张
取 消