Download presentation
Presentation is loading. Please wait.
Published byLorin Pearson Modified over 9 years ago
1
Computer Programs CS 1400 Dennis A. Fairclough Version 1.1 CS 1400 Dennis A. Fairclough Version 1.1
2
Overview Computer Programs –Data –Methods –Program Puts it all together Computer Programs –Data –Methods –Program Puts it all together 2
3
C# Data Integers (whole numbers) –int, sbyte, short, long (Signed) –uint, byte, ushort, ulong (Unsigned) Floating Point –double, float, decimal (Signed only) Others –char, bool Reference Type Objects –object, string Integers (whole numbers) –int, sbyte, short, long (Signed) –uint, byte, ushort, ulong (Unsigned) Floating Point –double, float, decimal (Signed only) Others –char, bool Reference Type Objects –object, string 3
4
Methods Console –Output to Display WriteLine(…) Write(…) –Input from Keyboard ReadLine(…) Read(…) Console –Output to Display WriteLine(…) Write(…) –Input from Keyboard ReadLine(…) Read(…) 4
5
Program class Program { void Main() { System.Console.WriteLine(“Hello, world!”); System.Console.ReadLine(); }//End Main() }//End class Program class Program { void Main() { System.Console.WriteLine(“Hello, world!”); System.Console.ReadLine(); }//End Main() }//End class Program 5
6
Program using System; class Program { void Main() { string sData = “”; int iData = 0; double dData = 0.0; Console.WriteLine(“Enter: string, int, double”); sData = Console.ReadLine(); iData = int.Parse(Console.ReadLine()); dData = double.Parse(Console.ReadLine()); Console.ReadLine(); }//End Main() }//End class Program using System; class Program { void Main() { string sData = “”; int iData = 0; double dData = 0.0; Console.WriteLine(“Enter: string, int, double”); sData = Console.ReadLine(); iData = int.Parse(Console.ReadLine()); dData = double.Parse(Console.ReadLine()); Console.ReadLine(); }//End Main() }//End class Program 6
7
Data Characteristics Size –int – 32 bits –double – 64 bits –char - 16 bits –string – length based on number of char’s + ‘\0’ Shape –char –int –double –string Methods –char –ToUpper(…), ToString(…) –int – Parse(…), ToString(…) –double – parse(…), ToString(…) –string – SubString(…), ToUpper(…) Size –int – 32 bits –double – 64 bits –char - 16 bits –string – length based on number of char’s + ‘\0’ Shape –char –int –double –string Methods –char –ToUpper(…), ToString(…) –int – Parse(…), ToString(…) –double – parse(…), ToString(…) –string – SubString(…), ToUpper(…) 7
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.