hi I get values from a textbox and i split it to a array.. Then i got the max value it is not saying real value;
here code is used
string[] cwatchers = textBox4.Text.Split('\n');
string[] sss = textBox1.Text.Split('\n');
string[] emails = textBox2.Text.Split('\n');
var sb = new StringBuilder();
sb.AppendLine("VERSION BUILD=8820413 RECORDER=FX");
sb.AppendLine("SET !ERRORIGNORE YES");
sb.AppendLine("SET !TIMEOUT_TAG 3");
sb.AppendLine("SET !TIMEOUT_STEP 3");
sb.AppendLine("SET !TIMEOUT_PAGE 7");
sb.AppendLine("SET !REPLAYSPEED FAST");
for (int i = 0; i < Convert.ToInt64(cwatchers.Max()); i++)
{
sb.AppendLine("TAB T=1").AppendLine("CLEAR");
sb.AppendLine("URL GOTO=https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&lgout=");
sb.AppendLine("WAIT SECONDS=1");
sb.AppendLine("TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:SIGNINFORM ATTR=ID:SUBMIT");
sb.AppendLine("SET !ENCRYPTION NO");
sb.AppendLine("TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:SIGNINFORM ATTR=ID:PASS CONTENT=Maths7524");
sb.Append("TAG POS=1 TYPE=INPUT:TEXT FORM=ID:SIGNINFORM ATTR=ID:USERID CONTENT=").AppendLine(emails[i]);
sb.AppendLine("TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:SignInForm ATTR=ID:sgnBt");
sb.AppendLine("WAIT SECONDS=7");
foreach (string item in sss)
{
sb.Append("URL GOTO=www.ebay.com/itm/").AppendLine(item);
sb.AppendLine("WAIT SECONDS=1").AppendLine("TAG POS=1 TYPE=SPAN ATTR=ID:watchLabel");
sb.AppendLine("TAG POS=1 TYPE=A ATTR=TXT:Watch").AppendLine("WAIT SECONDS=1").AppendLine();
}
}
label5.Text = cwatchers.Max();

label5 says max value is 70
as we can see max value is 180.. could anybody tell me why this is getting false ?
You need first to cast the elements to int, because now they are strings. Try something like this:
label5.Text = cwatchers.Max(x=>int.Parse(x));
This parses all the elements to int and then finds the max value. Notice that it will throw an exception if any of the elements can't be parsed to int.
Literally 70 is greater 180, as both are strings. Having said this what happens is that every character in your string is compared to the matching character in the other string at the same position. As "7" surely is greater "1", "70" also is greater then "180".
To avoid a lexical compairsion use a numerical instead, you have to treat your data as numbers:
var max = label5.Select(x => Convert.ToInt32(x)).Max();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With