O'Reilly logo

ASP.NET for Web Designers by Peter Ladka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required