Chapter04

397 views

Published on

หลักการเขียนโปรแกรมคอมพิวเตอร์เบื้องต้น โดยใช้ภาษา C# และใช้โปรแกรม RAPTOR ในการออกแบบ Flowchart

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
397
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
29
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Chapter04

  1. 1. Introduction to C# Programming Company LOGO
  2. 2.     C# Arithmetic Expressions) Raptor
  3. 3. C#     Programming – OOP) Object-Oriented .NET Java C++ .NET
  4. 4. .NET
  5. 5.  Text Editor csc.exe C:WINDOWSMicrosoft.NETFramework v4.0.30319 (VS 2010 Express)  Integrated Development Environment (IDE) Text Editor  Microsoft Visual C# 
  6. 6. C# Application) solution)  solution) project)   VC# -> Console Application
  7. 7. New Project
  8. 8. New Project
  9. 9. C# Namespace 2 class namespace Hello { 3 start point class HelloClass 1 { static void Main () { System.Console.WriteLine("Hello World!"); 4 System.Console.ReadLine(); } } code }
  10. 10.  Write WriteLine  Console System  System.Console.Write( "Hello"); Console.Write("Hello");  System using System;
  11. 11. Formatting String {index [,alignment] [:formatSpecifier]}  Console.WriteLine(" Two sample integers are { } and { }. ", ,  Index 0  Console.WriteLine("{0,-9}{0,9}", 12,45); 
  12. 12. Formatting String Console.WriteLine("x = {0} y = {1}",123,456); Console.WriteLine("123456789"); Console.WriteLine("{0,9}", 123); Console.WriteLine("123456789"); Console.WriteLine("{0,-9}End", 123); Console.WriteLine("123456789123456789"); Console.WriteLine("{0,-9}{0,9}", 123,456);
  13. 13. Formatting String E e Exponential ( F f Fixed-point ( G g General ( N n Number ( 2 Fixed-point comma P p Percentage ( X x Hexadecimal ( 3
  14. 14. Formatting String int n = 123456789; Console.WriteLine("{0:E}", n); Console.WriteLine("{0:F}", n); Console.WriteLine("{0:G}", n); Console.WriteLine("{0:N}", n); Console.WriteLine("{0:P}", n); Console.WriteLine("{0:X}", n);
  15. 15. Escape Sequence Escape Sequence n n t t r r " tab Backslash () " double quote (")
  16. 16. Escape Sequence Console.WriteLine("Welcome ntonC#nProgramming!");
  17. 17.  Read, ReadLine  System ReadKey Console
  18. 18.  Read ASCII Code) int a; Console.Write("Input : "); a = Console.Read(); Console.WriteLine(a); Console.ReadKey();
  19. 19.  Read ASCII Code) int a; Console.Write("Input : "); a = int.Parse(Console.ReadLine()); Console.WriteLine(a); Console.ReadKey();
  20. 20. 1. 2. 3. 4. Console.ReadKey() DOS
  21. 21. int a; float b; string c; char d; Console.Write("Input integer : "); a = int.Parse(Console.ReadLine()); Console.Write("Input float : "); b = float.Parse(Console.ReadLine()); Console.Write("Input string: "); c = Console.ReadLine(); Console.Write("Input character: "); d = char.Parse(Console.ReadLine());
  22. 22. Arithmetic Expressions) + * / % ++ -- Modulas 1 1
  23. 23. Arithmetic Expressions) = += A = 2; A +=1 A = A + 1; -= A -=2 A = A - 2; *= A *=3 A = A * 3; /= A /=2 A = A / 2; %= A %=2 A = A % 2;
  24. 24. Arithmetic Expressions) == != > >= 2 == 3 2 != 3 2>3 2 >= 3 < <= 2<3 2 <= 3 == 2 == 3
  25. 25. Arithmetic Expressions) && || ! ^ - / / - -
  26. 26. Arithmetic Expressions) 1 2 3 4 5 6 7 8 9 C# ( ) parenthesis – ++, -*, /, % +, ==, != && || =, +=, -=, /=, %= ++, --
  27. 27. Math Math.Abs(x) Math.Ceiling(x) Math.Floor(x) Math.Log(x) Math.Log x) Math.Round(x) Math.Pow(x,y) Math.Sqrt(x) Math.Max(x,y) Math.Min(x,y) Math.Sin(x) Math.Cos(x) x (|x|) x x x x x x y() x( ) x x x (x x (x y (2 y (2
  28. 28. Math Math.PI Math.E e
  29. 29.   string)
  30. 30. RAPTOR to C# Watch Window int BirthYear, Age;
  31. 31. RAPTOR to C# Input Console.WriteLine("Your Birth Year"); BirthYear = int.Parse(Console.ReadLine());
  32. 32. RAPTOR to C# Process Age = 2556-BirthYear;
  33. 33. RAPTOR to C# Output Console.WriteLine("You are " + Age + " Years old");
  34. 34. RAPTOR to C# int BirthYear, Age; Console.WriteLine("Your Birth Year"); BirthYear = int.Parse(Console.ReadLine()); Age = 2556-BirthYear; Console.WriteLine("You are " + Age + " Years old"); Console.ReadKey();
  35. 35.   4 /

×