|
The point is that the format specifier "000000%" multiplies by 100 and adds the percent sign.
So, given 15.00 the result of applying the above format string yields 001500%.
The percent sign is undesirable and needs to be striped out.
So the method I mention always strips out the % if it exists as I will never need to send a
percentage. So, I have accomplished my needs by still allowing standard formatting to be
used.
I could have created a custom format specifier "000000i", and then in my number processing
method look for i and then use implied decimal formatting.
|
|
|
|
|
Yes, I see that, but what I still don't understand is why you are doing
decimal.Parse ( d.ToString() ).ToString ( "000000%" ).Replace ( "%" , "" )
when
d.ToString ( "000000%" ).Replace ( "%" , "" )
should be all you need.
If the calling routine has the format string, why doesn't it simply use it?
Why do a bare ToString and then call this method... which first undoes the ToString?
Why not at least have this method take the decimal directly rather than a string?
|
|
|
|
|
You have assumed that I get the number as a decimal.
I get all the values as a string and also their type.
I also wanted to be able to default to "0.00 if no formatting
was supplied as most client are fine with that format.
1. I parse to decimal as I get it as a string.
2. I default to 0.00 if no format is given
3. I apply the formatting
4. I remove the % if exists
5. I return it as a string since if will be written to a flat file.
If the calling routine did the work and then I need this functionality some
where else then I have to maintain multiple copies. Maintaining the code in
a method allows me to for example default to 0.00
Besides at this point we are trying to impose our coding style on each other
which is fruitless. I appreciate your ideas but you haven't raised any points
that help me solve my problem any better.
|
|
|
|
|
Why do you re-write you tool such that you can choose which ever format you want to use.
Option 1: Include decimal point
Option 2: Exclude decimal point
|
|
|
|
|
That, can be done as well but then your adding code to the UI part of the tool
that will be used by possibly one client on only one type of field.
I know I am being picky. Currently an item that can be written to a flat file
has the following options:
Field:
Length: 10
Type: (float, int, etc)
Format: 0.00
Padding: Space
Padding Side: Right
Default Value: None
If I were to add a new field Implied Decimal
It would only apply to one type of all the types and therefore essentially a hack, in my opinion.
I realize that if the client can't fix this on his end I may have to put in a hack, but I am
trying to leave that as a last resort.
|
|
|
|
|
It is quite common to have "implied decimal" in an interface file, so it's not really a hack.
You should not need to have a new field, just need to make your tool more flexible in configuring the format of various numeric values (rates, amount, exchange rate).
|
|
|
|
|
Your probaby right.
However, I was trying to stick with the standard string formatting options.
In the end as I noted above I did the following:
I ended up using the format string "000000%" which multiplies by one hundred thus
given me the assumed decimal place. Then in my ProcessNumber method I remove the "%" if it exists.
The "%" will only exist if I am using the assumed decimal approach and I can still
use standard formatting for all clients.
Problem solved.
|
|
|
|
|
Just pray that the system doesn't use currencies that has no "cent", ie Won, Dong, Yen.
|
|
|
|
|
Yeah, I took that into consideration, the amounts are always even dollar amounts and always US currency.
thanks
|
|
|
|
|
I have a TreeView on my form as well as a ListBox. I have an Artist, Album and Song class which each extend the TreeNode class. The ListBox holds a list of songs which will be copied to a removable device. Now what I want to do is be able to drag an artist node, album node or a song node onto the list box and have all the songs under the dropped node show up in the ListBox. I know I need to use the DragDrop, Drag Enter and/or DragLeave events but I don't know how.
|
|
|
|
|
|
|
Ugh, well, im trying to write an app that will take a screenshoot and then proceed to send an email to our support ticketing software, all goes well, except for the fact that my attachment never gets through. I can send attachments and all fine from my client, but when attaching via code, it seems to just disappear. any ideas or known workarounds?
more or less the code:
<br />
MailMessage Mail = new MailMessage("fake@fake.com", "fake@fake.com");<br />
Mail.Subject = "testing ticket system";<br />
Mail.Body = "lalala wtf....";<br />
<br />
Attachment File = new Attachment(@"C:\Screenshot.jpg");<br />
Mail.Attachments.Add(File);<br />
<br />
SmtpClient SMTP = new SmtpClient();<br />
SMTP.Host = "somefakeserver.com";<br />
SMTP.Port = "25";<br />
<br />
SMTP.Send(Mail);<br />
message comes through, but no attachment.
|
|
|
|
|
I'm trying desperately to find a reliable and repeatable way to identify a given machine. One of the things I've tried is using the Win32_ComputerSystemProduct class. I wanted to use the UUID property, but on home-built systems (and indeed, even on some retail systems), this value is either all zeros or all F's.
How is this property value set? I did a search in the registry, but the search resulted in nothing being returned. Can this only set during the install of Windows?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
i hope this helps
although u probably gone there
[^]
UUID
Data type: string
Access type: Read-only
Universally unique identifier (UUID) for this product. A UUID is a 128-bit identifier that is guaranteed to be different from other generated UUIDs. If a UUID is not available, a UUID of all zeros is used.
Have Fun
Never forget it
|
|
|
|
|
Look at UUID MappingStrings qualifier, it's value is:
SMBIOS|Type 1|UUID
|
|
|
|
|
Hi John,
I just discovered Win32_BaseBoard.SerialNumber, maybe that suits your needs. Please let me know
what your conclusions will be, I have a similar need.
BTW: would Win32_ComputerSystemProduct.UUID remain constant when reinstalling (or upgrading) Windows?
|
|
|
|
|
Luc Pattyn wrote: I just discovered Win32_BaseBoard.SerialNumber, maybe that suits your needs. Please let me know
what your conclusions will be, I have a similar need.
Here are some things I've discovered in the last few weeks...
1) MAC addresses should never be used to identify a machine. Why? Because a machine could have two adapters (wireless and wired - like most modern laptops). If BOTH/ALL NICs are disabled, you can't get ANY mac address.
2) The BaseBoard serial number is almost always empty after the user updates the bios the first time. This is especially true on home-made desktop systems. None of my home systems (all home-built) have a baseboard serial number because all of them have had their BIOS's updated. My laptop has also had a bios update (twice in fact), yet it retains its original serial number.
3) I'd expect the Win32_ComputerSystemProduct.UUID to be the same after a windows install, but as previously pointed out, a home-built machine will probably not have a meaningful UUID. On the other hand, my Acer laptop has one, even without the original OS installed (it came with Vista, and I installed XP).
I figured setting a meaningless UUID from within my app would result in a UUID that isn't all 0's or all F's. Documentation is pretty scarce about this topic.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I always use the symbol '@' as a pointer to the first byte of a buffer, but what it means in C# now? Is it a reference or something?
What is the difference between string delimit = @"\"; and string delimit = "\";
Thanks,
Dirso
|
|
|
|
|
Dirso wrote: What is the difference between string delimit = @"\"; and string delimit = "\";
in C# the first compiles, the second does not, due to an invalid escape sequence.
|
|
|
|
|
In C# it means what it's always meant :P
In the case your showing it means 'literal string' i.e.
one which isn't processed and so theres no need to escape anything other than double quotes.
"////machinename//" == @"//machinename/"
It does also have another use which is to allow you to use reserved words as identifiers i.e.
public class @readonly {}
But that is not a good idea reserved words are reserved for a reason
|
|
|
|
|
originSH wrote: "////machinename//" == @"//machinename/"
I don't think so.
|
|
|
|
|
oh nuts ... yeah it should be:
"\\\\machinename\\" == @"\\machinename\"
Good spot
|
|
|
|
|
|
Thank you both! I had needed to use @ in Delphi so much that I completly forgot it's (not too good) use in C. And sorry for the horrible example in my question, of course "\" wouldn't compile, it was just a dummy question
Thank you so much,
Dirso
|
|
|
|