|
ziwez0 wrote: perhaps you should of read what I wrote, it was a question.
No you didnt, you just posted some code!
Perhaps you should buy a beginner book on C# and work your way through it!
|
|
|
|
|
Hi j4amieC,
J4amieC wrote: No you didnt, you just posted some code!
Suject "Why not True"
http://www.thefreedictionary.com/why[^]
I asked a question?, perhaps if you spent more time reading what people write, maybe your reponse might be helpful (like Alan's post), instead of your alternative which was a quick dismissal of someone's question.
|
|
|
|
|
Hi,
yes you are absolutely right, it does compile (well, after one adds type declarations for all the variables used), although it does not make sense whatsoever.
CompareTo returns an int
int.Equals(true) returns false no matter what.
It may help to read some documentation[^] especially if you insist on using methods you don't really need and apparently don't understand well.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:35 AM
|
|
|
|
|
Why use methods when operators will suffice?
|
|
|
|
|
is it because :
bool == 0; is false?
you are comparing an 'integer' to a 'bool' which is always false as they are different types
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
Ok
Lets break your code into steps
int result1 = StatusID.CompareTo(xGetStatusOID);
// result1 will be zero as the values are equal
bool result2 = result1.Equals(true);
//result2 will be false
The overload of Equals your code would call is
public override bool Equals (Object obj)
and the documentation says
The return value is true if obj is an instance of Int32 and equals the value of this instance; otherwise, false.
Alan.
modified on Wednesday, February 4, 2009 12:01 PM
|
|
|
|
|
|
The page you provided a link to discusses string comparison.
How does that relate to the original question?
Further more whether CompareTo returns 0, 1 or any other number is irrelevant as long as
you apply .Equals(true) to it, since that will ALWAYS return false.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:35 AM
|
|
|
|
|
Hi Luc,
Yes the link was a string comparision, but dont forget that Int32 Supports the CompareToMethod,
and they both return 0 if "strA equals strB."
And as mentioned I thought it would return 1 and not 0.
|
|
|
|
|
You read the wrong pages, you think you read the opposite of what they say,
you ignore earlier good advice, in short you don't have a clue.
I suggest a career change.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:35 AM
|
|
|
|
|
Thanks for that, keep up the good advice....
|
|
|
|
|
You still don't understand that comparing 1 to true would still return false anyway. So it is irrelevant whether CompareTo would return 0, 1 or PI, the result would always be false in your case.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi Greeeg,
thanks for taking the time to post, yeah your right, I was just expecting it to return 1 (true),
I was just curious, but after alans post made me look on MSDN, so it would be more like
if (i.CompareTo(ii).Equals(0)) ((0\1)and not true\false)
thanks tho.
|
|
|
|
|
good morning people, can someone tell me how can i adjust a pc's UTC by code?
|
|
|
|
|
You mean the time zone? Why would you need to? That shouldn't be done by software.
|
|
|
|
|
PIEBALDconsult wrote: That shouldn't be done by software.
Absolutely, the only legal way to change time zones is by traveling. There's nothing virtual about that.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:36 AM
|
|
|
|
|
Well, no, I can set my system to any time zone I want. But I don't want some program to do it without my knowledge and approval.
|
|
|
|
|
There may be other methods but try looking at WMI.
This article[^] might be a good starting point.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thanks man, thing is im using amazon simple storage service and when im making request (downloading/uploading objects) on a particular pc i get a 403 forbidden error, i have tried on many other computers and theres no problem, so i asked and they told me if my utc was off by more than 15 min it would give me this error, i checked utc on it and it was in fact very different than mine so i wanted to start there
|
|
|
|
|
That is a different problem!
That is a question of getting your PCs internal clock synchronised to a local Time-Server. This is one of the settings in Control Panel and it does it at a period you set when you connect to the Internet, unfortunately I cannot remember exactly where it is off the top of my head. Google for 'Time-Server AND sychronise'. That should get you sorted.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
i wanted do know how to fix it by code because i cant go to every pc thats gonna use this stuff and manually do it if this issue presents itself again,thanks man ill start there
|
|
|
|
|
If your clock is off, just set it.
|
|
|
|
|
i thinks its a little harder than that haha, my clock is good, the clock on the machine where im having problems is fine too, but when i do UTC.now i get different utc times on both mine and the troublesome computer, s3 works in my pc so i figured it was the other computer with an off utc
|
|
|
|
|
They're both set to the same time zone and display the same local time, but you get different UTC times?
|
|
|
|
|
yeah man i ran the exe in both computers, my utc was 7 hours later than my actual time, the other computer was 8 hours later than its actual time so the other pc got the forbidden error, weird right?
S3 will give you a 403 forbidden error if your utc time is off by more than 15 min, the computer from hell was off by an hour, no wonder it gave me the 403
|
|
|
|