Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Programming 1.  Editor Console Application Notepad Notepad++ Edit plus etc.  Compiler & Interpreter Microsoft.NET Framework  Microsoft visual.

Similar presentations


Presentation on theme: "Computer Programming 1.  Editor Console Application Notepad Notepad++ Edit plus etc.  Compiler & Interpreter Microsoft.NET Framework  Microsoft visual."— Presentation transcript:

1 Computer Programming 1

2  Editor Console Application Notepad Notepad++ Edit plus etc.  Compiler & Interpreter Microsoft.NET Framework  Microsoft visual studio 2005, 2008,(Full & Express)

3  The contents of your first console app appear as follows: using …..// call class to use namespace …..// define definition of class { class …..// name of class { static void Main()// starting write to program { // programming area }

4 Along the left edge of the code window, you see several small plus (+) and minus (–) signs in boxes. Click the + sign next to using.... This expands a code region, a handy Visual Studio feature that keeps down the clutter. Here are the directives when you expand the region in the default console app: using System; using System.Collections.Generic; using System.Text;  using System; Contain every class ex. Console to use input & output to display on monitor

5  Edit the test.cs template file until it appears as follows: using System; namespace ConsoleAppTemplate { public class Program { static void Main(string[] args) { Console.WriteLine(“Hello World !”); Console.WriteLine(“I am a bird !! in the sky”); Console.Read(); }

6  Console.WriteLine Display on monitor with add new line number on new cursor  Syntax:  Console.WriteLine(parameter);  Ex. Console.WriteLine(“Hello World!”);  Console.Write Display on monitor  Syntax:  Console.Write(parameter);  Ex. Console.Write(“Hello World!”);

7 Ex1. Console.WriteLine(“Hello World!”); Ex2.Console.Write (“Hello”); Console.Write (“ ”); Console.WriteLine (“World!”); This example are same as the result program Escape characterMean \nNewline \tHorizontal tab \”Double quotation mask \’Single quotation mask \\Backspace \rCarriage return \aAlert

8 using System; namespace ESCConsoleAppTemplate { public class Program { static void Main() { Console.WriteLine(“This line \tcontain two \ttabs”); Console.WriteLine(“This \ncontain new line”); Console.WriteLine(“This sound alert \a\a\a”); Console.WriteLine(“This \’ 555 \’”); Console.Read();// cursor waiting to any key }

9 Ex 3. Console.WriteLine(“Hello” + “World!”); Ex 4. String s = “Rujipan” Console.WriteLine(“My name is” + s + “and my Age is” + 33);  PlaceHolder Syntax: Console.WriteLine(“Statement {0} {1} {2} … {n}”,x0,x1,…,xn) {0} … {n}position to display x0 … xnvalue to {0}…{n} Ex 3. Console.WriteLine(“My name is {0} and Age is {1}”,”Boon”,45);

10 Syntax: {index [,alignment] [:format specific]}  Indexstarting 0  Alignmentamount of width display  Format specific FormatMean CCurrency as $ EExponential FFloating point GShot number NNormal number XHexadecimal number

11 using System; namespace DisplayFormat1 { public class Program { static void Main() { Console.WriteLine(“A={0} B={1}”,123,456); Console.WriteLine(“123456789”); // 9 number display 1234XXXXXX=space Console.WriteLine(“{0,9}”,1234); Console.WriteLine(“123456789”); // 9 number left align XXXXX1234 X=space Console.WriteLine(“{0,-9},1234”); Console.Read(); }

12 using System; namespace DisplayFormat2 { public class Program { static void Main() { Console.WriteLine(“{0:C}”,123456789); Console.WriteLine(“{0:E}”,123456789); Console.WriteLine(“{0:F}”,123456789); // floating point 2 position Console.WriteLine(“{0:F2}”,1234.12345); Console.WriteLine(“{0:G}”,123456789); Console.WriteLine(“{0:N}”,123456789); Console.WriteLine(“{0:X}”,123456789); Console.WriteLine(“{0,20:G}”,123456789); Console.Read(); }

13 using System; namespace ConsoleAppTemplate { public class Program { static void Main(string[] args) { Console.WriteLine(“Enter your name, please:”); string sName = Console.ReadLine(); Console.WriteLine(“Hello, “ + sName); Console.WriteLine(“Press Enter to terminate...”); Console.Read(); }


Download ppt "Computer Programming 1.  Editor Console Application Notepad Notepad++ Edit plus etc.  Compiler & Interpreter Microsoft.NET Framework  Microsoft visual."

Similar presentations


Ads by Google