13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

50<strong>ASP</strong>.<strong>NET</strong> <strong>3.5</strong>: A Beginner’s <strong>Guide</strong>Later, when you are using the monitor object (instance), it’s easy to remember it as aninstance of the Monitor class. If you need several instances of the Monitor class, thenyou’ll want to have some way of distinguishing between instances, such asMonitor redMonitor = new Monitor();Monitor greenMonitor = new Monitor();Monitor blueMonitor = new Monitor();The guiding rule in all labeling is to use <strong>com</strong>mon sense in the context of the project.Given that, just remember that your labels are case sensitive.NOTEIf you are familiar with JavaScript, Java, C++, or ActionScript 3.0, you will find manyof the same structures and formats that you will in C#. In time, Internet languages likeC# and JavaScript will have a <strong>com</strong>mon underlying set of structures in meeting certainEuropean Computer Manufacturers Association (ECMA) standards. You will finddifferences still, but ECMA is emerging as the language standard. For the full standardon C#, see <strong>www</strong>.ecma-international.org/publications/standards/Ecma-334.htm.Types, Statements, and ExpressionsLike most programming languages, C# deals with different types of data. For example,you may be familiar with numeric and string types. Numbers can be used for mathcalculations, and strings, for text storage. Assigning a value to a variable requires the datatype to be included in the declaration of the variable. For example, the following twovariables represent an integer declaration and a string declaration:string myString;int myNumber;A language that requires a type for variables, constants, and objects is a strictly typedlanguage, so C# can be considered strictly typed. Each <strong>com</strong>plete instruction, whether it issimply to declare a variable or some more <strong>com</strong>plex operation, is called a statement. Everystatement is terminated by a semicolon (;), and if the semicolon is left out, an error is thrown.Once you have declared a variable, you can then assign it a value. For example, usingthe variables we just declared, we could writemyString = "Happy programming";myNumber = 45;and the variables would now contain the values that we assigned. Any kind of statement thatresults in a value being assigned to a variable, constant, or object is called an expression.An expression can either be a simple assignment, or can be more <strong>com</strong>plex and involve

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!