|
John Simmons / outlaw programmer wrote: How do you do int, double, etc. without using ToString()?
Like normal...
list.Sort( (x,y) => x.Int.CompareTo(y.Int))
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
For integer values you can just subtract them:
products.Sort(delegate(Product x, Product y){return x.QuantityInStock - y.QuantityInStock;});
For double values you can use the Math.Sign method to get a suitable integer value from the difference:
products.Sort(delegate(Product x, Product y){return Math.Sign(x.Price - y.Price);});
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
After seeing that, I prefer to stick with the tried/true method of writing the various Comparison delegate functions. It's much easier to understand and maintain. When I code, I don't go "clever" nearly as often as I go "maintainable".
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
hi friends
what is the difference between == and Equals ?
what is the difference between close and dispose ?
how can i use object (object O = C) ? for what uses ? can i get sample ?
what is the uses for SendKey.Send ? can i get sample ?
thank's for any help
|
|
|
|
|
1) It depends on the language. In C++ == refers to the equality of the memory addresses of the two objects, and Equals refers to the equality of the memory address contents. In .NET I believe the two are basically the same.
2) Close allows the .NET garbage collection engine to work on its own. Dispose forces garbage collection of a particular object. Basically memory management. (Dispose usually still gets called eventually in the close method, but behind the scenes)
3) object O=(Object)C
4) SendKeys is a WinAPI command that allows you to emulate keystrokes from the keyboard and send them to the respective application.
Regards,
Thomas Stockwell
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.
Visit my Blog
|
|
|
|
|
Thomas Stockwell wrote: In .NET I believe the two are basically the same.
No[^].
Thomas Stockwell wrote: 2) Close allows the .NET garbage collection engine to work on its own. Dispose forces garbage collection of a particular object. Basically memory management. (Dispose usually still gets called eventually in the close method, but behind the scenes)
Dispose is usually used to free unmanaged resources like GDI handles, but it does not force garbage collection of an object.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Try following:
public bool isMyAnswers(MSDN msdn)
{
if (msdn.Website == <a href="http://msdn.microsoft.com/en-us/default.aspx">MSDN</a>[<a href="http://msdn.microsoft.com/en-us/default.aspx" target="_blank" title="New Window">^</a>])
{
bool answer1 = msdn.Search("==");
bool answer2 = msdn.Search("Dispose");
bool answer3 = msdn.Search("Object");
bool answer4 = msdn.Search("SendKey.Send");
msdn.Close();
}
if (answer1 && answer2 && answer3 && answer4)
return true;
return false;
}
While (true) { Human.isLearnable = true; }
|
|
|
|
|
E_Gold wrote: what is the difference between == and Equals ?
the == compares values and returns a Boolean, the = assigns a value.
Example
int a = 5;
int b = 5;
if (a == b)
{
}
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Sometimes (normally) none but not always. It depends on how the author of the object in question chose to implement it.
== is an overloadable comparison operator that is normally implemented something like this (note != would also HAVE to be implemented).
public static bool operator ==(MyObject myObjectA, MyObject myObjectB)
{
return (myObjectA.value == myObjectB.value);
}
Equals is an overridable method, and most Objects also implement IEquatable<objecttype> so the implementation is normaly something like this.
public override bool Equals(object obj)
{
if (obj is MyObject)
return Equals((MyObject)obj);
return false;
}
public bool Equals(MyObject other)
{
return this.value == other.value;
}
Notice this example implements the == operator in the Equal s method but it is not a requirement. It could test a totally different property or variable, if it's at the same location in memory (i.e. is the same object and not just the same value) or anything else.
Conclusion: You should check the documentation and/or experiment to see how they're evaluated. The object browser will often give hints when exploring the object. Reflector (google for it) can also be very useful as you can view the source to figure out what's going on if the assembly is not obsuficated.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hey everybody!
How do I reference different DLLs in release and debug?
Thanks!
|
|
|
|
|
Release or debug shouldn't matter. To add a reference to a dll (more easily done with a .NET dll), simply look for the references folder under the main solution for the project and right-click the references folder and then Add Reference. You will be asked for the location of the specific dll file.
Regards,
Thomas Stockwell
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.
Visit my Blog
|
|
|
|
|
It does matter.
In case in my solution I have several projects (one exe and many DLLs), and the EXE is referencing the DLLs.
When I'm compiling as debug I want to reference the Debug output of the DLLs, and when I am compiling release I want to reference the Release output.
|
|
|
|
|
You should use a project reference, that will automatically use the output of the current configuration.
If you want to reference a debug/release version of a DLL that's NOT part of your solution (so you cannot simply use a project reference), then edit the .csproj file with a text editor, look for the reference and replace "Debug" in its HintPath with "$(Configuration)".
|
|
|
|
|
|
hi eveybody, i have a problem, sorry about my english.
when i trying to request for youtube video which i want to download by segments (for that i use addrange), the addrange method doesnt work.
if i try to download from other servers (other downloads) the segments idea work fine, it splits the download with addrange method to parts.
but for some reason from youtube it start from the begining until the file is complete downloaded, and not split the file to segments with "addrange". i think because the server send me an http respone of UDP. but i dont sure. i saw many downloaders who succeed download youtube videos with segments.
maybe someone here knows the problem and can help me.
thnx asaf. =]
my code:
HttpWebRequest REQ = (HttpWebRequest)WebRequest.Create(url);
REQ.AddRange((int)pos, (int)poscount);
HttpWebResponse RES = (HttpWebResponse)REQ.GetResponse();
Stream input = RES.GetResponseStream();
FileStream output = new FileStream(@"c:\temp" + f, FileMode.CreateNew);
byte[] buffer = new byte[RES.ContentLength];
int B;
while ((B = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, B);
}
output.Close();
|
|
|
|
|
hi everybody
i want to set label text move like marquee in html
thanks for help
MD_NADA
|
|
|
|
|
Does it helps?[^]
"If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
|
|
|
|
|
The only HTML tag that exists is the <marquee> tag; take a look here for more info, although I would highly discourage use of it as its never been compatible with all browsers (only IE-based but I tried and it worked in Opera so perhaps other browsers started to include it when it started to become obsolete).
I'd recommend looking for a JavaScript ticker/marquee; something like this might help.
Regards,
--Perspx
"I've got my kids brainwashed: You don't use Google, and you don't use an iPod." - Steve Ballmer
"Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen an angry penguin charging at them in excess of 100mph." - Linus Torvalds
|
|
|
|
|
i am sorry maybe my question was not clear
but i depended on this posts not for ASP.NET
i work with desktop application and i want the label text like marquee in web (HTML)
i hope it is clear now
thanks for ur reply
MD_NADA
|
|
|
|
|
Hi All
I have two panel in my form, my 1st panel contains 3 buttons and the 2nd has 2 buttons, 3 textboxes and a label.
I need to get all of these controls to save their settings into a file, I tried:
foreach (Control ctrl in this.Controls)
MyFile.ReadLine(ctrl.Text);
But "this" has only two controls (My two panels) and I can't see the other controls contained in panels.
I know I can use the foreach statement for each of my panels but if I have a panel in panel2? Do you have any idea to solve this using only one loop?
Regards.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Each Panel has a Controls property, no?
|
|
|
|
|
Yes it has but I don't want to have a foreach statement per panel.
Thanks
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Well then, just find something else to do with your time. If it's not freakin' obvious what you have to do, and that "not wanting to" isn't a viable tack if you want to accomplish your goal, you shouldn't be a programmer. I bet you could find a job sweeping standing water off of sidewalks. Oh wait, that requires a little effort as well.
Oh wait! Try just staring off into space. That should keep your feeble excuse for a brain busy.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
You can use something like this:
foreach (Form frm in Application.OpenForms)
{
foreach (Control ctrl in frm.Controls)
MessageBox.Show(ctrl.Text);
}
This contains two foreach statement but indepedent of how many forms you have, you can get their controls.
zafer
|
|
|
|
|
You're right, but I have only one form, my form contains two Panels and each Panels contains some Controls.
Your foreach statements give me my Panels only.
Thanks
While (true) { Human.isLearnable = true; }
|
|
|
|