|
peterchen, are you looking to just compare 2 reference types? If so,
bool AreEqual<T>(T first, T second)
where T : class
{
return first == second;
}
|
|
|
|
|
I wanted it to work for both reference nad value types, and use overloaded comparison operators if any - but that doesn't seem possible in C#.
I've replaced the template type with object, and use IComparable if implemented, otherwise I fall back to comparing the references.
thank you.
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers! We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP Linkify!|Fold With Us!
|
|
|
|
|
You have to use the IEquatable interface.
More information on the "operator in generics" problem: www.codeproject.com/csharp/genericnumerics.asp[^]
Quote: The solution uses the fact that constraining type parameters using interfaces is not the same as casting to interfaces. Calling a method using an interface has the overhead of dynamic method dispatch, but calling a method on a type parameter that is constrained by an interface has no such overhead.
|
|
|
|
|
Dear All,
Let me know about the basics of windows Remoting & COM programming.Regards.
Raihan Masud
|
|
|
|
|
You might want to take a look here.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
i have a webpage with asp button. in server side, i wrote some code for its button click event to delete the page data.
but in client side i want user to confirm the deletion action. so i write this javascript code:
{if(confirm("do want to delete data...."))}
i don't know what to do to prevent page postback for false condition.
what should i do...
Thanks Rastgar
|
|
|
|
|
{if(!confirm("do want to delete data....")) return;
else do();}
|
|
|
|
|
i now 'if' parts and what 'return' does.
the thing that i don't know is how to stop my page from postback. but now i found it. to know that refer to my reply to guffa
Thanks Rastgar
|
|
|
|
|
Return a boolean in the click event of the button:
onclick="return confirm('Delete?');"
If the event returns false, the button click is stopped.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks alot.
but your sample code doesn't work or atleast i couldn't understand you and apply your method.
but i found another method in other forum. here it is...
{
if(confirm('do you want to delete?') return true;
if(document.all && window.event) event.returnValue = false;
return false;
}
it works so much better and do what exactly i wanted.
Thanks Rastgar
|
|
|
|
|
The code that I wrote does work, but the backwards way that this forum uses for "security" changed it.
Remove the * in the code:
o*nclick="return confirm('Delete?');"
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I want to make a for statement that displays the divide by sums like this:
1 / 1 =
2 / 1 =
3 / 1 =
4......
2 / 2 =
4 / 2 =
6 / 2 =
8......
Up until 5. How can i make that in a for statement?
Thanks in advance!
|
|
|
|
|
If you want help with your code, don't you think that you should at least make an attempt at writing any first?
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa,
I did! Just didn't worked out. This is what i had
for (int i = 1; i < 11; i++)
{
for(int j = 1; j < 11; j++)
{
answer = i / j;
}
}
|
|
|
|
|
This is okay, why doesn't it work?
Replace answer = i / j; with Console.WriteLine(j/i); to see the output.
Note that I replaced i/j through j/i, so that the divisions have a more readable order.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi Greeeg,
I guess it works but not the way i liked it to be.
It suppose to print this:
1 / 1 =
2 / 1 =
3 / 1 =
4 / 1 =
etc.
2 / 2 =
4 / 2 =
6 / 2 =
etc.
3 / 3 =
6 / 3 =
9 / 3 =
etc.
4 / 4 =
8 / 4 =
12 / 4 =
etc.
5 / 5 =
10 / 5 =
15 / 5 =
20 / 5 =
etc.
But instead of printing it like this, it prints this:
1 / 1 =
2 / 1 =
3 / 1 =
etc.
1 / 2 =
2 / 2 =
3 / 2 =
etc
1 / 3 =
2 / 3 =
3 / 3 =
etc
Like this up until "x / 10 =".
Do i have to make anther for statement in those 2 for statements?
|
|
|
|
|
Somehow like this:
for (int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
for (int k = j; k < j*5; k+=j)
{
Console.WriteLine(k + "/" + i);
}
}
}
It's bugged, but I don't know where the error is right now.
Just play around a bit with it.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
Thank you, i'll try a few things with it!
|
|
|
|
|
for(int i = 1 ; i < 11 ; i++ )
for(int j = 1 ; j < 11 ; j++ )
Console.WriteLine(j * i + "/" + i);
I think this is simpler.
|
|
|
|
|
Hi Adis,
That worked, thank you very much!
|
|
|
|
|
lets say I have 5 buttons and 1 text box
I want to get the text from all the button
so if I click one of the button the text of the same button
will be written in the textbox but!
I can use 5 event's
I only need to use on event.
please someone help me
|
|
|
|
|
Register the same event handler to all buttons, cast the sender parameter of the event handler from object to Button and finally access the button's text.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi...
What is the command for 'EchoOff' & 'EchoOn' in C# for SerialPort communication in C#.
Regards,
Vinay
|
|
|
|
|
Sounds like what you are really talking about it the echo from a modem, the serial port itself has no echo. If I am right it all depend on the modem you are using. Most "Hayes" modems use &E0 and &E1.
|
|
|
|
|
Hi!
I found this text when I serched MSDN for "unmanaged exceptions". Does anyone knows what it means?
""
Managed Code
In managed code, you cannot continue execution in the same thread after an unhandled exception. The thread terminates. If it is the program thread, the program itself terminates.
""
I have an application that simply terminates, NO exceptions, NO fault codes, NO dialog box saying: "an unhandled excep..."
|
|
|
|