|
leppie wrote:
tempstr.Substring(0, tempstr.LastIndexOf(".") - 1);
Dangerous. Days and fractions of seconds are optional. You could end up getting 8.01:01:01 (8 days, 1 hour, 1 minute, 1 second) and just return "8".
I'd guess the best way is
string str = String.Format("{0:00}:{1:00}:{2:00}", timespan.Hours, timespan.Minutes, timespan.Seconds)
but there may be a better way than that.
Paul
|
|
|
|
|
Thanks leppie and Paul -- That will work, yea I guess this is one for the FAQ on .NET.
|
|
|
|
|
I am looking for an intuitive way to allow users to reorder a treeview by dragging and dropping, though they can already drop on other nodes and update the hierarchy. So dropping on an item and inserting it before is not really an option. I currently have it such that when you dragover and right click you get a context menu that lets you insert before, but i'd like somehow to figure out when i'm inbetween two nodes. Anyone have any ideas.
Tanka
|
|
|
|
|
I am afraid the treectrl we know is not designed for rearrangement. What I would see is, when drag has begun, the treectrl folds and unfolds itself according to the mouse position, add space between items then show a xor drawn item (or set of items) to preview what the treectrl would look like with this item dropped here.
This requires work, but this would give you a lot of audience and attention...
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site. Support for development will ship at the same time as the Windows XP Service Pack 1 (SP1) release.
|
|
|
|
|
I'll do what I can. I'm looking for quite a bit more in a Tree control (ie multiple checkboxes) so I may have some fun later on. Thanks though
|
|
|
|
|
I have a function that takes a byte[], but the data i want to pass in is a string.
How do I convert?
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
|
i miss
byte* x = (byte*)p;
In the above list, I used
chars.CopyTo(bytes, 0)
and it bombed!!!
This should work.
Thanks
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
string str = "This is a test";
byte[] byteArray = new byte[str.Length];
for (int i=0;i < str.Length;i++)
byteArray[i] = (byte) str[i]; This has to be the most asked question in this forum. It just doesn't seem quite worth writing an article for, does it?
Paul
|
|
|
|
|
as far as i remember string is unicode. thus each character consists of 2 bytes. your code may work for ascii-characters, but the real solution would rather be something like:
string str = "This is a test";
byte[] byteArray = new byte[<font color=red>2*</font>str.Length];
for (int i=0;i < str.Length;i++)
{
<font color=red>int c = (int)</font>str[i];
byteArray[<font color=red>2*</font>i] = (byte) c;
<font color=red>byteArray[2*i+1] = (byte)(c>>8);</font>
}
or something similar...haven' tried the above code...
looking at the system.text-namespace is the best i believe...
:wq
|
|
|
|
|
Interesting point. I suppose it depends what you want the byte array for. If it's to store in a database then you might want to compress it.
Incidentally, your code wouldn't work either (at least I don't think so). str[i] returns a char so the high-byte of your int would always be zero.
This is fine in most cases but you might as well say
byteArray[2*i] = (byte) str[i];
byteArray[2*i+1] = 0; However all this is fairly acedemic since it was pointed out that System.Text.Encoding.ToByteArray.GetBytes(str) seems to do the job perfectly.
Paul
|
|
|
|
|
Paul Riley wrote:
str[i] returns a char so the high-byte of your int would always be zero.
char is unicode friendly, so the high-byte will depend on whether the text is ascii or unicode.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
It is? Gawd-damn! Amazing the things you can go around not knowing, isn't it?
Apologies to anyone I've misinformed on this one.
Paul
|
|
|
|
|
Look at System.Text.Encoding
|
|
|
|
|
Eric Gunnerson (msft) wrote:
Look at System.Text.Encoding
Well... that's a bit cool, ain't it?
Paul
|
|
|
|
|
Thank you
modified 29-Aug-18 21:01pm.
|
|
|
|
|
I think it's something like:
ASCIIEncoding ae = new ASCIIEncoding();
byte[] byStr = ae.GetBytes(str);
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
hi
it seems there is a new step accomplished on the road of generic implementation: it's called Gyro
see @
http://research.microsoft.com/projects/clrgen/
it looks cool
what do you thinks about it?
NB: it seems this guy deliver upgrade every 4 monthes since last year and this it beta .. perhabs a proposal at the end of the year??
|
|
|
|
|
Hi,
I would like to read/write a specific format to a flat text file. This format will contain delimiters like |, or space. I have been looking at the String class in C# to find somthing like string tokenizer. No any luck. Can someone help me out? Thanks!
|
|
|
|
|
string str = "this|is|a|test";
string[] arr = str.Split('|');
string str = "this|is,a|test";
string[] arr = str.Split('|', ',');
HTH
Paul
|
|
|
|
|
String.Split Method
String Class | String Members | System Namespace
Identifies the substrings in this instance that are delimited by one or more characters specified in an array, then places the substrings into a String array.
Overload List
Identifies the substrings in this instance that are delimited by one or more characters specified in an array, then places the substrings into a String array.
public string[] Split(params char[]);
Identifies the substrings in this instance that are delimited by one or more characters specified in an array, then places the substrings into a String array. A parameter specifies the maximum number of array elements to return.
public string[] Split(char[], int);
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
RegExp
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
hi..
i have a problem with my listbox,
it doesn't allow me to display turkish characters like "ü, ı, etc,.."
my editbox displays whatever i type in it but my listbox not!...
although i've changed listbox font settings (script=turkish, or font=Arial TR)
nothing changed...
All my religional settings works fine. i have no problem with displaying except from my listbox.
What should i do?
any help will be appreciated...
Thanks ,
Atilla Selem
just listening to you...
|
|
|
|
|
hi,
this is more a question on working with vs.net;
back in the c++-vs6-days there was an easy way to get a list of all virtual (or base-class) functions and have an overwrite-corpus in your code with one click.
i wouldn't know about things like WndProc or IsInputKey if i wouldn't have this forum here. is there any way in vs.net to easily get a list of the available virtual functions and say "i want to overwrite this" with one mouse-click?
thx.
:wq
|
|
|
|
|
Hi!
If you higlight a class then there is a button on the properties window that lets you override base class virtual functions with one click!
Cheers
HTH
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|