C programming from problem analysis to program design

This preview shows page 18 - 27 out of 31 pages.

C# Programming: From Problem Analysis to Program Design 18 Calling Class Methods Invoke a method Call to method that returns no value [qualifier].MethodName(argumentList); Qualifier Square brackets indicate optional Class or object name Call to method does not include data type Use IntelliSense
Image of page 18

Subscribe to view the full document.

C# Programming: From Problem Analysis to Program Design 19 Predefined Methods Extensive class library Console class Overloaded methods Write( ) WriteLine( ) Read( ) Not overloaded Returns an integer
Image of page 19
C# Programming: From Problem Analysis to Program Design 20 IntelliSense Method signature(s) and description After typing the dot, list of members pops up 3-D fuchsia colored box — methods aqua colored box — fields ( not shown ) Figure 3-2 Console class members
Image of page 20

Subscribe to view the full document.

C# Programming: From Problem Analysis to Program Design 21 IntelliSense Display string argument expected string parameter 18 different Write( ) methods Figure 3-3 IntelliSense display
Image of page 21
C# Programming: From Problem Analysis to Program Design 22 IntelliSense Display ( continued ) Figure 3-4 Console.Read ( ) signature Figure 3-5 Console.ReadLine ( ) signature
Image of page 22

Subscribe to view the full document.

C# Programming: From Problem Analysis to Program Design 23 Call Read( ) Methods int aNumber; Console.Write(“Enter a single character: ”); aNumber = Console.Read( ); Console.WriteLine(“The value of the character entered: ” + aNumber); Enter a single character: a The value of the character entered: 97
Image of page 23
C# Programming: From Problem Analysis to Program Design 24 Call Read( ) Methods ( continued ) int aNumber; Console.WriteLine(“The value of the character entered: “ + ( char ) Console.Read( )); Enter a single character: a The value of the character entered: a
Image of page 24

Subscribe to view the full document.

C# Programming: From Problem Analysis to Program Design 25 Call ReadLine( ) Methods More versatile than the Read( ) Returns all characters up to the enter key Not overloaded Always returns a string String value must be parsed
Image of page 25
C# Programming: From Problem Analysis to Program Design 26 Call Parse( ) Predefined static method All numeric types have a Parse( ) method double .Parse(“string number”) int .Parse(“string number”) char .Parse(“string number”) bool .Parse(“string number”)
Image of page 26

Subscribe to view the full document.

Image of page 27
  • Fall '08
  • BABB
  • Program design, Subroutine, Doyle

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern