|
Hi!
i want to sort an array containing DateTime of this format: 4/5/2007 8:43:34 PM, in ascending order, i.e. latest date/time on top...
Please give any ideas about this issue...
Thanks in advance...
Regards,
Affan Ahmad Toor
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
Probably a better method exists, you can anyhow try this.
Store the dates in binary format in an ArrayList. Do an ArrayList.Sort() and Arraylist.Reverse(); .
You can store date in binary using .ToBinary(); method and retrieve using DateTime.FromBinary(longDate) method.
|
|
|
|
|
If they are DateTime s then they will sort as stated.
If they are string s, they won't.
|
|
|
|
|
Hi,
since DateTime implements IComparable interface, you can do:
DateTime[] dt...;
Array.Sort(dt);
If it did not implement IComparable (or you want a different order), you would have
to provide a Comparer object as is:
public class DTComparer : IComparer {
public int Compare(object odt1, object odt2) {
DateTime dt1=(DateTime)odt1;
DateTime dt2=(DateTime)odt2;
long diff=dt1.Ticks-dt2.Ticks;
if (diff<0) return -1;
if (diff>0) return 1;
return 0;
}
}
public void demo() {
DateTime[] dt=new DateTime[]{
DateTime.Now.AddDays(1),
DateTime.Now.AddMinutes(1),
DateTime.Now.AddHours(1)
};
log(dt);
Array.Sort(dt, new DTComparer());
log(dt);
}
public void log(DateTime[] dta) {
log("DateTime[]:");
foreach (DateTime dt in dta) log(" "+dt.ToString());
}
|
|
|
|
|
Hello Luc,
It's allways a pleasure reading your explanation!
All the best,
Martin
|
|
|
|
|
|
Luc,
Thanks alot for the help, it solved my problem...
Looking forward for more help from you in future...
cheers!
Regards,
Affan Ahmad Toor
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
I am in a small project about an application about storing, monitoring and pricing orders. I am completely in charge of the project (from analysis to tests) and I have 3 months in total to complete it (so think of about 1+ month of programming and some more weeks of fixing bugs and adding features during the test period) with 30 hours/week at most.
The company is small. The budget for new technologies is almost inexistent (they will barely afford to increase server's ram from... 128MB(!) and possibly upgrade an old win2000 machine). They want a specialised client fitted to their (quite limited) needs.
I know C# and ASP.NET (not an expert, but I do have experience in various projects). As the users will be few and non-concurrent, ASP.NET was simply not worth the effort (they are not thinking of working over internet).
I could have a simple Access database (back end) and leave to the chief manager a front end with graphs+reports on how to make his own graphs to observe whatever he wants to, and do all the rest of the application in c# clients.
But some advised me of doing everything in Access Forms. I checked this a bit more, and show that possibly Data Access Pages is a better idea. The questions are:
-are Data Access Pages going to be faster in the development? They seem so with their close integration to access, but then i fear that messing with VBScript will slow down the process (I dislike scripting languages)
-is Excel integration (as it will be helpful for pricing) in Data Access Pages strong enough to make up for the lost advanced GUI functionality I can have with WinForms?
In both cases some pretty advanced (think of DataRepeaters on drugs) functionality will be welcome if it's easily implemented.
The back end database could be used with other clients even if the company expands within reason (turning from micro to large is not even in the business plans).
--Victory, Not Vengeance
|
|
|
|
|
Ok, I suppose nobody came up with a reason to use DAP over c# :P
|
|
|
|
|
hello
i use httpwebrequest & httpwebresponse in this page
http://www.codeproject.com/cs/internet/httpeep.asp
i test this code in many site it work verrry good
but when i test this code with this site
https://isp.paltel.net/login.cfm
i have problem ???
please help me plzzzzzz
where the problem and how can solve this problem ????
Palestine
|
|
|
|
|
You don't mention at all what your problem is, so it is kind of hard to know how to help.
Are you getting an error message? An exception?
Ben
|
|
|
|
|
--------------------------------------------------------------------
TrustFailure - The underlying connection was colsed : could not estabilsh trust relashionship for SSL/TLS secure channel
--------------------------------------------------------------------
Palestine
|
|
|
|
|
Ok I missed that the second url was https:.
I haven't actually done this with a Httpwebrequest object, but looking at the documentation it looks like you need to add a client certificate.
Here is the MS help:
An application can add a certificate to a collection, but might not have access rights to it. To use a certificate contained in the collection, the application must have the same access rights as the entity that issued the certificate.
Note
The Framework caches SSL sessions as they are created and attempts to reuse a cached session for a new request, if possible. When attempting to reuse an SSL session, the Framework uses the first element of ClientCertificates (if there is one), or tries to reuse an anonymous sessions if ClientCertificates is empty.
Note
For performance reasons, you shouldn't add a client certificate to a HttpWebRequest unless you know the server will ask for it.
For a code example illustrating how to enumerate the certificates in the client certificate store, see the X509Certificate2Collection class.
Ben
|
|
|
|
|
main problem who can open untrust site with HttpWebRequest ??
Palestine
|
|
|
|
|
the see this error message
--------------------------------------------------------------------
TrustFailure - The underlying connection was colsed : could not estabilsh trust relashionship for SSL/TLS secure channel
--------------------------------------------------------------------
Palestine
|
|
|
|
|
You don't need to put the same question in multiple forums.
__________________
Bob is my homeboy.
|
|
|
|
|
I have the following interface
public interface IImage
{
string FileName { get; set;}
string Caption { get; set;}
} I have a class called Image that implements the interface.
I create a BindingList of that Image object:
BindingList<Image> images = new BindingList<Image>(); I later want to store images in a list defined as the interface.
BindingList<IImage> = images; Why am I getting a casting error? If I understand the rules of polymorphisms correctly, so long as my Image class implements IImage, I can store any Image as an IImage without needing to explicitly cast.
What to do?
-Mike.
|
|
|
|
|
MBursill wrote: BindingList<iimage> = images; // casting error
Why am I getting a casting error? If I understand the rules of polymorphisms correctly, so long as my Image class implements IImage, I can store any Image as an IImage without needing to explicitly cast.
See, as per polymorphisms you asign a object of the drived class to a base class. But in the above case the "BindingList<iimage>" is not a base class to the "BindingList", hence you are not able to assign them. Its actually the items they contains have relation of base class - drive class.
Manoj
Never Gives up
|
|
|
|
|
MBursill wrote: BindingList images = new BindingList();
Do the following
BindingList<IImage> images = new BindingList<IImage>();
|
|
|
|
|
hi,
Can you help me ?
c # directory file version and configuration version and product version as information how reader ?
I can't find
Thanks
hi
|
|
|
|
|
Hi,
1) If you want to know the Operating System Information, here is the code:
System.OperatingSystem OperatingSysInfo = System.Environment.OSVersion;
2) If you want to know the Platform, you can get it from
OperatingSysInfo.PlatForm enumrator.
similarly you can check for many information in the object of the OperatingSystem.
Manoj
Never Gives up
|
|
|
|
|
Good Morning ,
Thanks.But I want not operating system read information , I want cd , floppy disk , network , partion(C,D) whichever one (folders , file) reader (product version, file version , configuration version) information ..
Can you help me ?
Thanks .
hi
|
|
|
|
|
Hi,
You can use the DirectoryInfo class to get the info of the drvie and folder and even files.
Manoj
Never Gives up
|
|
|
|
|
hi,
Yes , I can use the directory whichever file version and product version knife information ...
can you give me e-mail address? detail some formation tell
thanks
hi
|
|
|
|
|
Even after reading lots of articles about dispose, I still have some very annoying doubts...
For instance, a have an application that makes intence use of userControls. This user controls encapsulates a lot a Windows Forms Controls, and a COM object.
Doubts:
- Do I have to call dispose for every Windows Forms Controls in my UserControl's dispose?
- I've been told to use System.Runtime.InteropServices.Marshal.ReleaseComObject() to free the resources of my COM object. Is that necessery?
- I know that I shold dispose any bitmaps loaded. Does that means that I need to dispose an image of a picturebox, like picturebox1.image.dispose()? Or simply calling picturebox1.dispose() will do the job?
- What else do I need to dispose anyway? My userControl has a few arrays of strings, Colors and Images. I'm only disposing the images.
Thanks a lot
Peterson
|
|
|
|