Chapter 8 Object-Based (Web hosting solutions) Programming 333 1 // Fig.
Chapter 8 Object-Based Programming 333 1 // Fig. 8.19: AssemblyTest.cs 2 // Using class Time3 from assembly TimeLibrary. 3 4 using System; 5 using TimeLibrary; 6 7 // AssemblyTest class definition 8 class AssemblyTest 9 { 10 // main entry point for application 11 static void Main( string[] args ) 12 { 13 Time3 time = new Time3( 13, 27, 6 ); 14 15 Console.WriteLine( 16 “Standard time: {0}nUniversal time: {1}n”, 17 time.ToStandardString(), time.ToUniversalString() ); 18 } 19 } Standard time: 1:27:06 PM Universal time: 13:27:06 Fig. 8.19 Fig. 8.19Fig. 8.FiFi19g. 8.19g. 8.19Assembly TimeLibraryused from class AssemblyTest. Before class AssemblyTest can use class Time3, the project containing class AssemblyTestmust have a reference to the TimeLibrary assembly. To add the reference, select Add Reference from the Project menu. Using the Browse button, select TimeLibrary.dll (located in the binDebug directory of the TimeLibrary project), then click OK to add the resource to the project. After adding the reference, use keyword using to inform the compiler that we will use classes from namespace Time- Library(line 5 in Fig. 8.19). 8.17 Class View and Object Browser Now that we have introduced key concepts of object-based programming, we present two features that Visual Studio provides to facilitate the design of object-oriented applica- tions Class View and Object Browser. The Class View displays the variables and methods for all classes in a project. To access this feature, select Class View from the View menu. Figure 8.20 shows the Class View for the TimeTest1 project of Fig. 8.1 and Fig. 8.2 (class Time1 and class TimeTest1). The view follows a hierarchical structure, positioning the project name (TimeTest1) as the root and including a series of nodes (e.g., classes, variables, methods etc.). If a plus sign (+) appears to the left of a node, that node can be expanded to show other nodes. By contrast, if a minus sign (-) appears to the left of a node, that node has been expanded (and can be collapsed). According to the Class View, project TimeTestcontains class Time1 and class TimeTest1 as children. Class Time1 contains methods SetTime, Time1, ToStandardString and ToUniversalString (indicated by purple boxes) and instance variables hour, minute and second (indicated by blue
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.