C# Example

This section takes the ball class from Chapter 2 and compiles it as an object that will be available to the ASP.NET application.

Here is the ball class.

ball_cs.cs
namespace Peter.Toybox {

    public class Ball    {
        private string _Color; 
        private string _Motion; 

         public Ball(){
            _Motion = "Still"; 
        } 

        public string Color{
            get {
                return _Color; 
            } 
            set {
                _Color = value; 
            }   
        } 


        public string  Motion {
            get {
                return _Motion; 
            } 
        } 

        public void Roll() {
            _Motion="Rolling"; 
        } 
    } 
} 

Enter this source example into your favorite text editor and save this as ball_cs.cs.

After you have the file saved, you can try to compile it. On my machine, the files are saved in d:\websites\book\app_b\. If your files are stored in a different location, the exact sequence of commands ...

Get ASP.NET for Web Designers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.