X hits on this document

1265 views

0 shares

0 downloads

0 comments

22 / 396

Chapter ‎18   Unsafe code

Local constant declaration

static void Main() { const float pi = 3.1415927f; const int r = 25; Console.WriteLine(pi * r * r); }

Expression statement

static void Main() { int i; i = 123;// Expression statement Console.WriteLine(i);// Expression statement i++;// Expression statement Console.WriteLine(i);// Expression statement }

if statement

static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("No arguments"); } else { Console.WriteLine("One or more arguments"); } }

switch statement

static void Main(string[] args) { int n = args.Length; switch (n) { case 0: Console.WriteLine("No arguments"); break; case 1: Console.WriteLine("One argument"); break; default: Console.WriteLine("{0} arguments", n); break; } } }

while statement

static void Main(string[] args) { int i = 0; while (i < args.Length) { Console.WriteLine(args[i]); i++; } }

do statement

static void Main() { string s; do { s = Console.ReadLine(); if (s != null) Console.WriteLine(s); } while (s != null); }

Copyright Microsoft Corporation 1999-2003. All Rights Reserved.9

Document info
Document views1265
Page views1265
Page last viewedFri Jan 20 10:59:18 UTC 2017
Pages396
Paragraphs9401
Words133190

Comments