The conversion into months in negative scenario is what I am not getting.
I'm not sure what you mean by this but using a TimeSpan object will get you the number of days difference, and using the Abs() method will get you the number as a positive integer. Converting that into months and years requires some logic which takes into account leap years and the number of days in each month, none of which is impossible, it just requires a little extra thought.
One of these days I'm going to think of a really clever signature.
The general way to get the difference between two DateTime values is just to subtract and get a TimeSpan. A TimeSpan only goes as high as Days, not months or years because doing so is rather difficult -- you must take the varying lengths of months and Leap Days and into account.
It were easy and reliable, it would be built-in. If you really want to do this, you're on your own. I seem to recall that someone else asked about this a few months back, but a quick search didn't turn it up.
you must take the varying lengths of months and Leap Days and into account.
I'm not saying that it's right, or that anyone should do it, but what about the Datediff function in the Microsoft.VisualBasic namespace? There you'r able to get the difference in months and years without that hassle.
But saying that, I've not used that namespace in a C# solution.
No, there is no limit I am aware of, and a quick test says that you can use more than 3852 points anyway:
Point points = new Point;
Random r = new Random();
for (int i = 0; i < points.Length; i++)
points[i] = new Point(r.Next(0, 200), r.Next(0, 200));
privatevoid panel1_Paint(object sender, PaintEventArgs e)
Pen p = Pens.Red;
Works with no problems. I would suspect the problem is in your other code.
BTW: You shouldn't create a new Pen like that - you are responsible for calling Dispose on all graphics elements you create, so you should keep a reference to it, or use a stock item as I did.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
I received a C# 2008 console application from a contract shop to work with. The purpose of the console application is to consume data it receives from a web service. (The contract shop that wrote the web service also wrote the console application I am suppose to work with.)
My questions are the following:
1. The console application writes to a log file. The only results I can see that can come from the log file is a dos window that displays while the application is running. If this is true, can you tell me how to have the log file write to a different location?
2. When I run the console application, I sometimes see error messages that show up in the dos popup window. At first I thought the error messages came from the web service. However today I opened up an *.xsd file and I see alot of the error messages that appeared in the dos window the last few days. Thus can you tell me how to determine how the *.xsd file is wired to the application? I would like to learn how the code is called.
3. Can I step through the code that is executed from the *.xsd file? If so, how would I accomplish this task? Do I need certain debug options set?
1. I'd guess they are using TraceListeners[^]. The one you're probaly after is the TextWriterTraceListener[^]. The link has a code snippet on how to implement the TextWriterTraceListener to help get started. The first link shows how to setup a listener declaratively using the config file. This is the better way to go because you can control your listeners without recompiling the application.
I’m using Visual Studio 2008and I started a Window’s Form project in C++.
I want to switch it overto C#. I realize that I will have to basically re-write the operational code, and the functionality behind the forms, but what I want to do if I can is"import" the form designs to C#.
I’m only interested in the placement of the boxes and buttons etc., not the coding that links one form to the next or the operational code behind each button.
Is there an easy way to copy / import the forms from C++ to C#?
This is a question related to yesterdays "Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly....." I have found an oddity with the data I am reading in at odd times I get "\n" appearing (it's serial data) I am using a foreach() loop to split up the data coming in with one one the delimiters being "\n" I'm guessing that as there are two next to each other it see one kills it and lets the other pass,
Resulting in a blank line. If I use
if (subString == "\n")
with out effect
I have got it so it creates the a save file as
the commented out lines have been tried and found not to work (also the if Contains does nothing), I was trying to avoid using the StreamReader / Writer and BinaryReader /Writer as I am a little of how they work also I am attempting to read data from a board I read in the past with out using them.
Last Visit: 31-Dec-99 18:00 Last Update: 21-Sep-23 22:27