Wednesday, 15 July 2009

String.format Help

For those of you who are doing .NET development, if you have the trouble of finding out what references what in string.format to output exactly what you want. Here is a guide: -

formatting stringsThere's not much formatting that can be applied to a string. Only the padding / alignment formatting options can be applied. These options are also available to every argument, regardless of type.

example output
String.Format("--{0,10}--", "test"); -- test--
String.Format("--{0,-10}--", "test"); --test --

formatting numbers
Number formatting is culture dependant. For example, formatting a currency string on my laptop will return a result like £9.99, formatting a currency on a machine set for the US region would return $9.99.

specifier type format output
(double 1.2345) output
(int -12345)
c currency {0:c} £1.23 -£12,345.00
d decimal
(whole number) {0:d} System.FormatException -12345
e exponent / scientific {0:e} 1.234500e+000 -1.234500e+004
f fixed point {0:f} 1.23 -12345.00
g general {0:g} 1.2345 -12345
n number {0:n} 1.23 -12,345.00
r round trippable {0:r} 1.23 System.FormatException
x hexadecimal {0:x4} System.FormatException ffffcfc7


custom number formatting
specifier type format output
(double 1234.56)
0 zero placeholder {0:00.000} 1234.560
# digit placeholder {0:#.##} 1234.56
. decimal point placeholder {0:0.0} 1234.6
, thousand separator {0:0,0} 1,235
% percentage {0:0%} 123456%


In addition there is the group separator; this is useful for varying the format, depending on the value of the parameter passed. For example

String.Format("{0:£#,##0.00;(£#,##0.00);Nothing}", value);


This will output "£1,240.00" if passed 1243.56. It will output the same format bracketed if the value is negative "(£1,240.00)", and will output the string "Nothing" if the number is zero.

date formatting
Date formats are very dependant on the culture information passed. The examples below are shown using the UK culture.

specifier type output
(June 8, 1970 12:30:59)
d Short Date 08/06/1970
D Long Date 08 June 1970
t Short Time 12:30
T Long Time 12:30:59
f Full date and time 08 June 1970 12:30
F Full date and time (long) 08 June 1970 12:30:59
g Default date and time 08/06/1970 12:30
G Default date and time (long) 08/06/1970 12:30:59
M Day / Month 8 June
r RFC1123 date string Mon, 08 Jun 1970 12:30:59 GMT
s Sortable date/time 1970-06-08T12:30:59
u Universal time, local timezone 1970-06-08 12:30:59Z
Y Month / Year June 1970


custom date formatting
specifier type output
(June 8, 1970 12:30:59)
dd Day 08
ddd Short Day Name Mon
dddd Full Day Name Monday
hh 2 digit hour 12
HH 2 digit hour (24 hour) 12
mm 2 digit minute 30
MM Month 06
MMM Short Month name Jun
MMMM Month name June
ss seconds 59
tt AM/PM PM
yy 2 digit year 70
yyyy 4 digit year 1970
: seperator, e.g. {0:hh:mm:ss} 12:30:59
/ seperator, e.g. {0:dd/MM/yyyy} 08/06/1970

--It's helped me tremendously :)

Tuesday, 14 July 2009

Any Good Free Virus Checkers out there??

Apart from the usual Norton's anti-virus, I pondered if there were any decent free virus checkers out there...after much searching for the ultimate virus checker, I stumbled upon this avast! which looked pretty impressive, with three/four seperate components to scan your computer - standard, network, p2p, and mail shield but after 2 months of using it, I don't think it is that comprehensible, and useful to people as it doesn't really notify you many messages such as if it is scanning or not.

I typed in the keywords best virus checker, and found this post. Following my instincts, I will find out if this free virus checker is any good and keep you posted.

"Alice J" <> wrote in message
newsRJFc.3072$
>| I need a good virus checker. FREE please.....I don't want AVG
>| because I heard it fails a lot of tests. I won't use or pay for
>| kaspersky because I don't trust Russian spammers. And Nortons just
>| sells rubbish.
>|
>| Can someone recommend the best FREE virus checker that I can
>| download??....One with
>| regular updates PLEASE!! ;o)
>|
>| Alice

This will get you free for a year - auto updates, all that. And it's better
than AVG.
http://www.my-etrust.com/microsoft/

Thursday, 9 July 2009

OCZ's Sabre OLED Gaming Keyboard Launched




For those of you who are super-gaming geeks, there is a much cheaper OLED Gaming Keyboard with 9 "tactile" OLED gaming keys on the far left hand side launched by OCZ.

It boats a tilt of 5-10 degrees, a digital image that can be converted to any design onto the OLED button which in turn lights up programmable to do anything such as a macro or command in a game or a shortcut key in Windows, and has even a blue LED side light effect around the edges of the keyboard.

See the link http://www.zipzoomfly.com/jsp/ProductDetail.jsp?ProductCode=10010701