Overblog Suivre ce blog
Editer l'article Administration Créer mon blog

Présentation

  • : Romagny13 - Du .NET,du pur .NET
  • Romagny13 - Du .NET,du pur .NET
  • : Cycle de progression Faire (quelque chose qui marche) -> comprendre ce que l’on fait/comment cela marche -> pousser plus loin les notions
  • Contact

Recherche

Articles Récents

11 avril 2014 5 11 /04 /avril /2014 17:16

1- Opérateurs

           // 1 

            int? x = null;

            int y = x ?? -1; //si x est null y = -1 sinon y vaut x

 

            // 2

            int? a = null;

            int? b = 5;

            int c = a ?? b ?? -1; // c=5 si a et b avaient été "null" alors c aurait été égal à -1

 

            // 3

            bool p = false;

            int result = !p ? 0 : 1; // si p est false result = 0 sinon result=1    

 

2-string.Format() et ToString()

 

// ToString() + localisation 

decimal price = 9.99M;

MessageBox.Show(price.ToString("C",new CultureInfo("en-US")));

// string.Format 

MessageBox.Show(string.Format("{0:C}", 9.99M));


Nombres

C or c Currency $12,345.67

D or d Decimal (integer types only) 12345

E or e Scientific notation 1.234567E+004

F or f Fixed-point 12345.67

G or g General (fixed-point or scientific, whichever is shorter) 12345.67

N or n Number (with decimal and thousands separators) 12,345.67

P or p Percent (multiplied by 100 and % added) 0.12 becomes 12.00 %

X or x Hexadecimal (integer types only) 3039

 

DateTime

d: 6/15/2008

D: Sunday, June 15, 2008

f: Sunday, June 15, 2008 9:15 PM

F: Sunday, June 15, 2008 9:15:07 PM

g: 6/15/2008 9:15 PM

G: 6/15/2008 9:15:07 PM

m: June 15

o: 2008-06-15T21:15:07.0000000

R: Sun, 15 Jun 2008 21:15:07 GMT

s: 2008-06-15T21:15:07

t: 9:15 PM

T: 9:15:07 PM

u: 2008-06-15 21:15:07Z

U: Monday, June 16, 2008 4:15:07 AM

y: June, 2008

 

'h:mm:ss.ff t': 9:15:07.00 P

'd MMM yyyy': 15 Jun 2008

'HH:mm:ss.f': 21:15:07.0

'dd MMM HH:mm:ss': 15 Jun 21:15:07

'\Mon\t\h\: M': Month: 6

'HH:mm:ss.ffffzzz': 21:15:07.0000-07:00

T Long time 2:15:16 PM

y or Y Year/month March, 2014

 

Partager cet article

Repost 0
Published by Romagny13 - dans C
commenter cet article

commentaires