|
Hi,
the number of addresses in the interval[ a.b.c.d , e.f.g.h ]
equals num32(e,f,g,h) - num32(a,b,c,d) + 1
where num32 is the 32-bit number formed by those 4 byte values, as in:
num32(a,b,c,d) = ((((((a<<8)+b)<<8)+c)<<8)+d);
BTW: you may save a few lines of code using IPAddress.GetAddressBytes(),
unfortunately there seems to be no method IPAddress.GetAddressInt32() !
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
WOW exactly what i needed!!!! THANK YOU!!!
|
|
|
|
|
How can I load a XML into a rich text box?
l_szCurrentFile = m_szDirectory + "\\" + m_oTabControl.SelectedTab.Name.ToString();
rtbDoc.LoadFile(l_szCurrentFile, RichTextBoxStreamType.RichNoOleObjs);
I get an invalid file type error with this
|
|
|
|
|
I think your problem is caused by "RichNoOleObjs ." According to the help file, "This value is only valid for use with the SaveFile method of the RichTextBox control."
Try using PlainText (or UnicodePlainText .)
BDF
|
|
|
|
|
<br />
<br />
using (StreamReader sr = new StreamReader(@"N:\test2.xml"))<br />
richTextBox1.Text = sr.ReadToEnd();<br />
<br />
good luck
|
|
|
|
|
I have to write a program converting a csv file into a huge xml file, about 100 elements.
Is the best way to just create a class xmlfile.cs
then read the info from another class pass the values to xmlfile one by one, then when done use xmlwriter, in the same class, to write the whole file?
Is there a better way?
Thanks
|
|
|
|
|
There are several CSV parsers on this site, have you searched them?
Generating the XML...I guess fill them into an array and serialize that using an XML serializer. Will that work?
|
|
|
|
|
Yes I have seen and practiced with a couple. It may be more overhead but i actually like using the excel object to parse the files I find it to be easier and it works better in my head.
Thanks
|
|
|
|
|
Ok. Is your question answered, then, regarding serializing the CSVs to XML file?
|
|
|
|
|
Yes i am new to xml and serialization is a much better way than i was doing. Thanks again
|
|
|
|
|
you may also want to look at vtd-xml
http://vtd-xml.sf.net
|
|
|
|
|
hi friends!
i have little prob i u can plz help me.
Q.1 I have to enter login and logout time in database in SQL through c# the prob is everytime i try to do it ,it goes in two diff rows is there any other way tht i can feed it in same row n later find total used time?????
Q.2 how to display time coz using DateTime.Now.TimeOfDay.ToString() gives me time in miliseconds bt i want it only till minutes?
plz help me guys.......
|
|
|
|
|
Q.1 doesn't make much sense. If you need to start both the sign-in and sign-out times in a single row, then your row will need 3 column values:
-An ID: e.g. some unique value identifying the row.
-The sign-in time
-A nullable sign-out time.
When you first sign in, create a new row with a new ID, the sign-in time, and a null sign-out time. When you sign out, find that row by the unique ID and update it's sign-out time.
Q.2 Sounds like you're looking for DateTime.Now.ToShortTimeString() .
|
|
|
|
|
thanks friend it worked though the first one still not perfect thanks
|
|
|
|
|
I have an array of some odd 100k 3d points. I want to rotate them around an axis. What is the quickest way of rotating them? I suspect that it might have something to do with a matrix, but I dont know much about them.
Thanks,
|
|
|
|
|
Yes, matrices are what you need to look into. Are you using XNA? MSDN describes the XNA Matrix class[^]. See the links in the article for How-To's on how to transform (e.g. move, rotate, etc.) 3d points using matrices.
|
|
|
|
|
No I am not using XNA, or WPF. All I really have is a custom structure made up of three double values to define a 3d point. I see that there is a matrix class in c#. And in actuallity I would be fine even with a 2d rotation, though 3d would obviously be better.
|
|
|
|
|
GreenGiant83 wrote: I would be fine even with a 2d rotation
Check out System.Drawing.Drawing2d.Matrix class. There are other classes in the Drawing2d namespace that may help you with your rotations.
Alternately, you *could* use the free Lutz Reflector[^] tool to see how XNA's Matrix class rotates 3d rotations, then do a little copy & paste job into your own code.
|
|
|
|
|
I have found lots of articles explaining how to use the matrix class to do rotation with GDI+ stuff, the problem is that the GDI stuff takes the matrix and processes it. As I am not wanting to rotate graphics, but the actual data points themselves these articles do not help me much. Can anyone shoe me or point me to an article that can show me how to several points and rotate them, matrix math or otherwise?
Thanks,
|
|
|
|
|
I mentioned reverse-engineering XNA's Matrix class and seeing the multiplications done to the 3d points (a struct in XNA called Vector3). You should do this and look at the methods on there, such as Matrix.CreateRotationX, .CreateRotationY, .CreateRotationZ. See how those methods are applying rotation to 3d points, then you can implement a similar solution on your end.
If you're curious about how matrices work from a mathematics perspective, see Wikipedia's article on matrix multiplication[^].
|
|
|
|
|
Hi all
I'm totaling up a list of items in a Binding source and I am just having a small problem with syntax for incrementing the value of a key if it already exists
any help is greatly appreciated line 16 below
[code]SortedList mySortedList = new SortedList();
foreach (DataRowView view in myBindingSource)
{
if ((string)view["group_name"] == "USAT-Desktop")
{
view["group_name"] = "TEST TEST";
}
if (mySortedList.Contains(view["category_name"])== false)
{
mySortedList.Add(view["category_name"], 1);
}
else
{
//how do I ++ the value of the key if it already exists?
//mysortedlist[view["category_name"]].value +=1?
}[/code]
|
|
|
|
|
Hi,
mysortedlist[view["category_name"]] = 1+(int)mysortedlist[view["category_name"]];
should do it.
BTW: the above code line was set inside <pre> </pre> tags;
they work much better than [code] [/code] !
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I'll give it a try
sorry about the tags I always forget going from form to form this one is a little different
|
|
|
|
|
that works great I just tried it
thanks so much I was close but I don't think I would have gotten that for a while
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|