|
for my present problem statement i should be able to change it n restore it back...
yup changing it wil effect the file n sometime file may not open also
|
|
|
|
|
They both appear to do the same thing, except Object.Equals documentation says that it throws a NullReferenceException . I can't get it to do that though.
They both test for equality of instances, they both take the same parameters, and they are both static members of System.Object .
I am implementing equality comparison using the standard overrides and operator overloads. I am frustrated with these little details that seem unnecessary.
Documentation says:
Object.ReferenceEquals Method
Determines whether the specified Object instances are the same instance.
Object.Equals Method
Determines whether two Object instances are equal.
EDIT:
I figured it out, I stepped through the code and learned that the static Object.Equals(object a, object b) called in the operator overload actually makes a call to the virtual instance-level Equals(object obj) , so the static ReferenceEquals has to be used to test for instance equality. Though by default the static Object.Equals(object a, object b) will do the same thing as the static ReferenceEquals , unless you override the instance-level Equals method, because by default, the instance-level equals tests for instance equality.
public class Foo : IEquatable<Foo>
{
public static bool operator !=(Foo foo1, Foo foo2)
{
return !Equals(foo1, foo2);
}
public static bool operator ==(Foo foo1, Foo foo2)
{
return Equals(foo1, foo2);
}
public bool Equals(Foo foo)
{
if (foo == null) return false;
return y == foo.y && x == foo.x;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj)) return true;
return Equals(obj as Foo);
}
public override int GetHashCode()
{
return y + 29*x;
}
private int y;
private int x;
}
modified on Thursday, October 29, 2009 2:48 PM
|
|
|
|
|
The answer is simpler than you think... Here's an example:
public class MyClass
{
public string Value { get; set; }
public override bool Equals(object obj)
{
MyClass other = obj as MyClass;
return (other != null && other.Value == Value);
}
}
MyClass a = new MyClass() { Value = "Test" };
MyClass b = new MyClass() { Value = "Test" };
Now... These are two entirely different objects, that happen to contain the same contents. In this case, Equals() returns true, but ReferenceEquals() returns false.
The basic concept is that Equals() indicates logical equivalence... Dunno if that's the right term... It tests whether the two objects are equivalent in terms of what they contain (At least, it's supposed to - You're supposed to override it in classes you create). ReferenceEquals() always tests whether two references point to the same physical object in memory.
EDIT:
CaptainSeeSharp wrote: if (ReferenceEquals(this, obj)) return true; //why use Object.ReferenceEquals here and not Object.Equals(obja, objb)?
//They do the same exact thing as far as I can tell
To add... That's a shortcut. ReferenceEquals() is a much faster operation, since you're just testing whether two pointers are equal. Obviously if the two references point to the same object, testing Equals() (Which may have a lengthy implementation, such as comparing every element in an array) is superfluous.
|
|
|
|
|
Just beat me to it!
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.”
|
|
|
|
|
Didn't quite answer my question, but thanks anyways.
|
|
|
|
|
Object.Equals tests for Equality i.e. the two objects have the same values. Take a look at the example code on the MSDN Page for a demo.
Object.ReferenceEquals tests if they are in fact the same object i.e. it is the same pointer.
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 figured it out, I stepped through the code and learned that the static Object.Equals(object a, object b) called in the operator overload actually makes a call to the virtual instance-level Equals(object obj) , so the static ReferenceEquals has to be used to test for instance equality. Though by default the static Object.Equals(object a, object b) will do the same thing as the static ReferenceEquals , unless you override the instance-level Equals method, because the default instance-level Equals method tests for instance equality.
modified on Thursday, October 29, 2009 2:48 PM
|
|
|
|
|
hi every one
how can record video from desktop?
Thanks a lot
|
|
|
|
|
behzadcp wrote: how can record video from desktop?
Wow, you have a Surface?
Seriously, you are likely to get a quicker answer if you google/bing/yahoo for c# video capture.
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.”
|
|
|
|
|
|
Printscreen is no video µ
Just an image
|
|
|
|
|
_Madmatt wrote: Printscreen is no video
Really? I had no idea! Thanks for the HUGE tip!
Maybe, just maybe I was being sarcastic as the OP left no information allowing others to help him, how he wanted to capture a video, using his own software or interfacing with third party software, what format, anything of the sort! Way to go!
|
|
|
|
|
EliottA wrote: Maybe, just maybe I was being sarcastic as the OP left no information allowing others to help him, how he wanted to capture a video, using his own software or interfacing with third party software, what format, anything of the sort! Way to go!
Yes indeed, the question is very clear...
EliottA wrote: Really? I had no idea!
He had no idea, maybe he's testing it right now? :p
|
|
|
|
|
Original Post wrote:
hi every one
how can record video from desktop?
Thanks a lot
Yes, extremely clear. I'm sure he is fast on his way to 'record video desktop'.
Stop being a tool.
|
|
|
|
|
EliottA wrote: Stop being a tool.
You mean "stop being a fool"?
Maybe he isn't in a hurry for an answer?
|
|
|
|
|
No, I meant steop being a tool.
|
|
|
|
|
Do I hear sarcasm? Lol, however the answer to the question willn't come. Maybe we could stop spamming all around here.
|
|
|
|
|
|
Tell me why? Why should I be a "tool"?
|
|
|
|
|
You're a tool because all you're doing is attempting to aggravate me while spamming the boards.
You're a tool.
|
|
|
|
|
I'm spamming the boards? Look around! It's you who said I' a tool, it's you who said "use printscreen" while that's totally wrong... You're such a ****** ***
|
|
|
|
|
Click Here[^] if you want to record using some software
Click Here[^] if you want to make such software using c#
|
|
|
|
|
hi there,
i have recently posted a Question asking how to send and recieve raw ethernet packets (bits on the wire) to the dialup (or any kind of modem) Modem's Connection, i have searched a lot and found and downloaded a Library Called SharpPcap (managed code for WinPcap) that can exactly do what i want, but only over Lan Connection and when i was trying to send packets over Dialup connection it fails,
someone answers me and tell me to send packets using SerialPort class, since Modems are connected to the computer using serial ports(like COM1 or COM2)
now suppose that my dial up modem is connected to the internet and is at port COM1, i'll wrote something like this:
<br />
SerialPort sp = new SerialPort("COM1",9600);<br />
sp.DtrEnable = true;<br />
sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);<br />
sp.Open();
sp.Write(....My Packet);<br />
as i specify it throws me an exception, since this port is Opened now and is owned by a process, and as long as ports(such as COM1) can only be used by one and only one process, i can not do any thing...
is there another way or something else, i've searched for 2 or more weeks ...
|
|
|
|
|
AT COMMAND LIST[^]
Have you considered to send AT command to modum to dial specific number
|
|
|
|
|
i didn't ask what to send to modem, i have asked how to communicate when the port is opened by another process and i want to open() it and send AT Commands!??
|
|
|
|