|
I'm sure there's lots out there. Maybe you folks have your favorites?
|
|
|
|
|
Have one, but in C++. Would have to go dig it up. Also have a good one for Hamiltonian Cycles, again in C++.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
|
I need just a simple console program to tell how many days and hours (minutes if possible) until this persons next birthday.
He was born on July 26th 1983 at 8:00 pm.
I'm really new at this and I wanted to give him a small exe (console program) for his birthday.
This is all I oould come up with so far:
using System;
class myApp
{
public static void Main()
{
DateTime CurrTime = DateTime.Now;
DateTime JimBDay = DateTime.Compare(CurrTime, "08/01/2008");
Console.WriteLine("Jim's Birthdate: ", JimBDay);
Console.WriteLine("Jim's Birthday is July 26th at 8:00 pm");
Console.WriteLine("{0:F}", CurrTime);
// Need some code to say there are this many days and this many hours until your next birthday (minutes if possible).
Console.Read(); // wait
}
}
|
|
|
|
|
you can use subtract Method to get days and hours and minutes and seconds difference between two date.
see this code:
DateTime CurrTime = DateTime.Now;
DateTime JimBDay = new DateTime(1983,7,26,20,0,0);
TimeSpan span= CurrTime.Subtract(JimBDay);
now span has days and hours and minutes and seconds difference between jim birthday and now.
Human knowledge belongs to the world
|
|
|
|
|
|
JimBDay does not show up on Console.WriteLine("Jim's Birthdate is... ", JimBDay); it just says "Jim's Birthday is..."
and
"span" shows as 9132.03:46:30.4287493 / How can I format this to say...
This many months...
This many days...
This many hours...
and
This many minuts until your next birthday?
using System;
class myApp
{
public static void Main()
{
DateTime CurrTime = DateTime.Now;
Console.WriteLine("Right now the date and time are: {0:F}", CurrTime);
DateTime JimBDay = new DateTime(1983, 7, 26, 20, 0, 0);
Console.WriteLine("Jim's Birthdate is... ", JimBDay);
TimeSpan span = CurrTime.Subtract(JimBDay);
Console.WriteLine(span);
Console.Read();
}
}
|
|
|
|
|
You'll have to pick apart the pieces from the span. There's Days, Minutes, and other properties to investigate.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
try these properties:
Console.WriteLine(span.Days.ToString());
Console.WriteLine(span.Hours.ToString());
Console.WriteLine(span.Minutes.ToString());
Console.WriteLine(span.Seconds.ToString());
Console.WriteLine(span.Milliseconds.ToString());
Human knowledge belongs to the world
|
|
|
|
|
First you need to find the next birthday. Create a DateTime value for the birthday this year (from the current year and the month and day from the birthday). If it has passed, add a year to the value.
Now you just subtract the current date from the value, and you get a TimeSpan that holds the time difference.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i have a client.exe and c# program. . my exe can open only with my program. my exe cannot open alone.when i click button1 on my program , client.exe will open. But when i double click to client.exe , client.exe cant open.
how can i do this ?
|
|
|
|
|
Please clean up your question. It really makes no sense and is confusing
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi there.
I have Visual Studio 2008.
I want to use this class HttpUtility.HtmlDecode
I couldn't find it in System.Web
Where is it ?
|
|
|
|
|
You have to add a System.Web.dll class library to your project's references.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
|
I see how you can bind to a checkedlistbox for one item to be checked. but what if you have multiple items selected. How can you bind that?
here would be my code for one checked item
fooCheckedListBox.DataBindings.Add("SelectedValue", fooDataSource, "SomePropertyinMyBindingSource");
But I have multiple selected values.
|
|
|
|
|
I have windows form where I am adding control at run time but I couldn't remove them all. Some of them get removed but some stays there. I have spent already 4 hours nothing making sense why I couldn't simply remove controls from the form.
this.Controls(btn);---> this is how iam adding Controls
foreach (Control c in this.Controls)---> this is how am removing-->no achievement
{
this.Controls.Remove(c);
}
=========
but if copy all the controls to an arraylist and then it works. What a nosense is this is C#
ArrayList a = new ArrayList();
foreach (Control c in this.Controls )
{
a.Add(c);
}
foreach (Control cc in a)
{
this.Controls.Remove(cc);
}
modified on Saturday, July 26, 2008 4:01 PM
|
|
|
|
|
Every iteration of your foreach loop is incrementing an index,
but you're removing a control so all the other controls are shifted
up one in the collection. That means you'll miss every other control I
suppose
Maybe something like this:
for (int i = this.Controls.Count - 1; i >= 0; i--)
{
this.Controls.RemoveAt(i);
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote:
for (int i = this.Controls.Count - 1; i >= 0; i--)
{
this.Controls.RemoveAt(i);
}
...or...
foreach (Control c in Controls)
c.Dispose();
Controls.Clear();
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Much better
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
A honeyed cute version of yours I'd say.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Hi,
Control.Controls is a collection with normal functionality.
As Mark said, you can't (reliably) modify a collection with a foreach loop.
However, isn't this.Controls.Clear() what you want?
|
|
|
|
|
How do I dispose the control before or after removeAt?
What i think about Controls.Clear() is that it doesn't remove resources taken by the object. It stays alive in the memory but Controls.Remove remove the object and it's resources. Corrrect me what you think of that
|
|
|
|
|
Neither of them remove the resources taken by the object.
Only the reference is removed from the collection. If there's
no more outstanding references, the objects will eventually
get cleaned up. You should iterate through and dispose any
disposable objects, however, to prevent leaks.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
netJP12L wrote: Controls.Remove remove the object and it's resources
I don't think so. The documentation clearly says:
ControlCollection.Remove Method "Removes the specified control from the control collection."
No more, no less.
The way I read this the Control is not modified, it just is removed from its parents Control list.
The Control remains intact, you can continue to use it, either as a hidden Control,
or you can add it to some other Container/Form/whatever.
The only method that clears resources is Dispose(); once called, the Control should not be used
any longer.
Besides, for Clear the documentation says: "Removes all controls from the collection."
Same verb, only difference is "all".
QED
|
|
|
|