vbdotnet.it

Tricks & tips, workaround, forum and ideas with .Net

About the author

Enrico Rossini è il gestore di questo blog.
E-mail me Send mail

Recent posts

Recent comments

Contributi

Best 6 ~ 6 users ~ 6 comments

Info legali

Le opinioni espresse in questo blog sono strettamente personali e ogni persona è responsabile dei commenti che inserisce. I marchi citati sono delle rispettive aziende.

© Copyright 2010

Advertising


Formattazione con String.Format

formatting strings

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

formatting numbers

specifiertypeformatoutput
(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

specifiertypeformatoutput
(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%

date formatting

specifiertypeoutput
(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

specifiertypeoutput
(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

Currently rated 3.0 by 2 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: asp.net | Generalità | vb.net
Posted by enrico on Friday, August 07, 2009 11:15 AM
Permalink | Comments (0) | Post RSSRSS comment feed

[OT] Superiorità totale!

Desidero rendervi partecipi della mia esperienza odierna con C# e VB.NET perché ha dell'incredibile! Voglio realizzare una nuova intranet per la mia azienda: mi sono fatto preparare la pagina web con il CSS dalla mia grafica e ho cominciato alle 16 di oggi a realizzare l'intranet.

Per provare qualcosa di diverso, ho deciso di farla in C#!!! La prima cosa che volevo creare era un webservice che salvasse sul database un log. La complicazione era data dal voler utilizzare ADO To Entity che ho ancora avuto modo di provare. Creo il webservice utilizzando Aggiungi | Nuovo elemento. Crea un semplicissimo webservice con la funzione HelloWorld e già da qua un caterva di errori non identificati visto che non avevo ancora scritto del codice. Dopo quasi 30 minuti scopro grazie a Davide che il problema era che il file era stato creato in modo completamente errato!

Bene. Creo quindi - già un po' innervosito - il file dell'entità partendo dal database: neanche conclusa la creazione mi restituisce l'errore "Token non valido 'void' nella dichiarazione del membro della classe, della struttura o dell'interfaccia". EEEEHH? Sul file che ha creato lui?? È fuori??? Ricreo 27 volte la stessa entità e alla fine non dà errori.

Cominciò a modificare il webservice per salvare i dati sul database: nessuno, dico, NESSUNO degli esempi trovati su internet e sui vari libri riesce a spiegarmi come fare. Niente di tutte le funzioni trovate riesce a fornirmi delle indicazioni interessanti anche perché fanno riferimento a delle classi che io non ho e non trovo (si veda ad esempio http://blogs.msdn.com/wriju/archive/2008/10/16/ado-net-entity-insert-update-and-delete-with-relationship.aspx). Dove caspita trova queste classi generate dall'entità? Sarà un'entità paranormale...

Non ne vengo fuori, il debug non funziona e al massimo ottengo o una pagina vuota o una pagine di errore 500. Alle 21 ovvero 5 ore dopo stò per lanciare il pc fuori la finestra!

Sconsolato, apro un nuovo progetto web in VB. Creo il file dell'entità dallo stesso database e delle stesse tabelle. Creo un webservice e creo la funzione di salvataggio. Eseguo...

FUNZIONA TUTTO SUBITO SENZA ERRORI!!!

VB the best! VB is the most beatiful! VB is the most productivity! VB is the best!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: Work around
Posted by enrico on Wednesday, May 20, 2009 9:59 PM
Permalink | Comments (0) | Post RSSRSS comment feed