|
// Load start date and end date from database.
if(currentdate > startdate && currentdate < end)
{
// current date is between start and end date.
}
else
{
// It's not.
}
[EDIT]
(You can get the current date by doing DateTime.Now)
[/EDIT]
Simon
modified on Tuesday, April 1, 2008 12:26 PM
|
|
|
|
|
DateTime.Compare() method returns -1 if the date is less than the value compared to, +1 if greater and 0 if the same.
public bool TestDateWithinBounds(DateTime StartDate, DateTime EndDate, DateTime DateValue)
{
if (DateValue.CompareTo(StartDate) == -1)
return false;
if (DateValue.CompareTo(EndDate) == 1)
return false;
return true;
}
Dave
|
|
|
|
|
I don't know why anyone would vote your answer down. it looks good to me. Here, have a 5.
Simon
|
|
|
|
|
Thanks
Dave
|
|
|
|
|
Hi, I try use a number (decimal) wrote in a commandline of my program.
I use
string args = System.Environment.CommandLine;
and args shows "PathofMyApp\NameofMayApp.exe" .7 --------> .7 is a commandline argument
I need use this .7 in a line
this.Opacity = varWhenIsTheDecimalNumber;
I resume. I need a way to use the .7 .8 .5 .2 or .AnyNumber
I hope that somebody understand me
Thanks,
|
|
|
|
|
Hi,
I would:
- call Environment.GetCommandLineArgs() to get all the parts of the command line
as a string array (the first part will be the path of the executing EXE),
- check the number of elements in that array
- use Decimal.TryParse() to parse the decimal argument
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- 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 PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi, Luc, thanks for your answer, I tried but I am very inexpert (supernewbie is my first day with C#), and cannot works.
I declared
string[] args;
Follow I call:
args = Environment.GetCommandLineArgs();
But, how do I use it? this.Opacity use 'double' format data and Enviroment.GetComandLineArgs give me 'string[]' data. I am very confused .
Ok, thank new and again, I search more and maybe learn more. If you have some additional tips, Thanks a lot!!!!
Bye
|
|
|
|
|
Hi,
a command line is just text, so it is only natural Environment.CommandLine
and Environment.GetCommandLineArgs return one or several strings.
to interpret a textual representation of some data, you need to "parse" it;
most primitive data types provide a Parse() and TryParse() method for exactly that
purpose.
if you need a double, and your input format is likely to be in an acceptable format
for it (as in .7), then just do bool success=double.TryParse(myString, myDouble)
When in doubt, look it up; the documentation is eager to be your friend.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- 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 PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
bool success=double.TryParse(myString, out myDouble)
|
|
|
|
|
you know that, I know that; however I'm not in the spoon feeding business,
I am plugging documentation here.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- 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 PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Very thanks!!!!!!!!!!!
It works very good
<br />
args = Environment.GetCommandLineArgs();<br />
double.TryParse(args[1], out d);<br />
this.Opacity = d;<br />
Now I will make that when the argument in the commandline don't exist, set a default Opacity 1.0.
I will try.
Thanks, Bye
|
|
|
|
|
Hello Friend!
I've built a windows application.
now I want to show any gif image while system is busy to save data in data base. after completing save operation the image will be invisible. again it will be visible during saving data.
How can I do this?
Please, help me.
Thanks!!!!!!!!!!
|
|
|
|
|
1. show image
2. use a delegate to the save method, and call begininvoke
3. in the callback, remove the image
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);
Morgonen är tröttmans mecka
|
|
|
|
|
Thanks!
Can u give me any small code example explaining delegate
|
|
|
|
|
abc.aspx this is my first page . and xyz.aspx is open if click a button .
if close xyz.aspx then refresh the abc.aspx.
Regard
Bhagwan Chaubey
hi this is bhagwan chaubey
|
|
|
|
|
Is xyz.aspx a popup window?
|
|
|
|
|
chaubeyb wrote: abc.aspx this is my first page . and xyz.aspx is open if click a button .
C# forums this is. If close, then go to correct forum and post question.
|
|
|
|
|
what you want to know ..explain
|
|
|
|
|
Hi,
I have read in 1 book that the STATIC function Object.Equals() check the object values and Object.ReferenceEquals() check their references.
For Ex- Suppose i have a user defined class - Person
Person p1 = new Person( 1,"ABC");
Persion p2 = new Person( 1,"ABC");
Object.Equals( p1, p2 ) -> returns true. // compares the state
Object.ReferenceEquals( p1,p2) -> returns false.// compares the reference.
The output should be like this as specified in that book. But am not getting like this. We cant overide static functions too. Any Idea? It would of great help.
Regards
|
|
|
|
|
|
You'll have to override the protected method Equals inherited from Object.
This flavor is my own personal favorite, note the use of the private Equals.
. I also like overloading the == operator.
namespace PersonTest {
class Program {
static void Main(string[] args) {
Person p1 = new Person { Member = "ABC", OtherMember = 1 };
Person p2 = new Person { Member = "ABC", OtherMember = 1 };
Console.WriteLine(Object.Equals(p1, p2).ToString());
Console.WriteLine(Object.ReferenceEquals(p1, p2).ToString());
Console.ReadLine();
}
}
public class Person {
public String Member { get; set; }
public Int32 OtherMember { get; set; }
public override Boolean Equals(Object obj) {
return obj is Person ? Equals(obj as Person) : false;
}
private Boolean Equals(Person obj) {
if (Object.ReferenceEquals(this, obj)) return true;
if ((obj == null) || (this == null)) return false;
return obj.Member == this.Member && obj.OtherMember == this.OtherMember;
}
public override int GetHashCode() {
return base.GetHashCode();
}
}
}
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Hi,
If we are overriding the protected method Equals(), then whats the difference between the usage of virtual function Equals() and static function Equals defined in the Object class.
|
|
|
|
|
The static method Equals(object.object) uses the virtual method Equals(object). You just have to override the Equals(object) method in your Person class.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hello,
I have, on a PC, two Network Adapters.
I need to test the quality of these interfaces, with a cross link.
I have written a small program in C# with a client socket and a server socket.
But I want to be sure that exchange is going on the cable, and NOT inside the network layers of the PC.
So I want to bind the client socket and the server socket each to one of the interfaces.
The function I want to use is in the following code :
Socket xPortSend;
//...
byte[] AdapterId = ????
int iRet = xPortSend.IOControl( IOControlCode.BindToInterface, AdapterId, null );
1) I don't know how to find the Adapter Id of each network interface ?
2) Which is the exact synthax to use with the function "IOControl" ?
Some samples on this call will be very helpfull ?
Best regards.
|
|
|
|
|
hello ,
is it possible to create a c# application that detect if the PC is shuting down
best regards
dghdfghdfghdfghdgh
|
|
|
|