public partial class Test : Page { private Car car1, car2; protected override void OnInit(EventArgs e) { base.OnInit(e); /// /// new car object /// car1 = new Car(); /// /// new car object with inline constructor /// car2 = new Car() { Color = "Blue", Price = 45000, MaxSpeed = 200, Bhp = 300 }; /// /// set properties /// car1.Color = "Black"; car1.Price = 25000; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); /// /// Call methods /// car1.Drive(); car1.Reverse(); } protected void Button_Clicked(object sender, EventHandler e) { /// /// Call methods /// car1.Drive(); car1.Turn(); car1.Drive(); /// /// Call methods /// car2.Reverse(); car2.Turn(); car2.Drive(); car2.Turn(); car2.Drive(); } } public class Car { /// <summary> /// Automatic Properties /// </summary> public string Color { get; set; } public double Price { get; set; } public int MaxSpeed { get; set; } public int Bhp { get; set; } /// <summary> /// Construcotrs /// </summary> public Car() { this.Color = "Red"; this.Price = 30000; this.MaxSpeed = 140; this.Bhp = 335; } public void Drive() { /// /// Implement how to drive /// } public void Reverse() { /// /// Implement how to reverse /// } public void Turn() { /// /// Implement how to turn /// } }
Saturday, July 24, 2010
How to use object oriented concepts (classes and objects) in a asp.net web page - C# , Asp.net
Subscribe to:
Post Comments (Atom)
Azure Storage Account Types
Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...
-
Why we need asynchronous tasks? Execute a time consuming operations in parallel to the CLR thread which execute the request If you have ...
-
Demo: I was thinking a way to show images before actually uploading them to server. I would say to preview images using javascript. Obv...
No comments:
Post a Comment