O reilly learning path enterprise web programming pdf download






















These classes have rich, consistent sets of properties and methods and can be referenced in code like controls on forms are referenced in GUI applications. This separation of web page layout from code results in pages that are easier to develop and maintain. NET automatically detects the capabilities of the end user's browser and adjusts its output accordingly. Browser-based applications are discussed in detail in Chapter 6.

NET Chapter 2. NET language, including basic concepts such as variables, operators, statements, classes, etc. Some material that you'd expect to find in this chapter will seem to be missing. NET applications, yet they are not introduced in this chapter because they are not intrinsic to the Visual Basic. They are provided by the. NET Framework and will be discussed in subsequent chapters. Additionally, Visual Basic. NET functions that exist merely for backward compatibility with Visual Basic 6 are not documented in this chapter.

NET source code is saved in files with a. The exception to this rule is when Visual Basic. NET web page files.

Such files have an. Source files are plain-text files that can be created and edited with any text editor, including our old friend, Notepad. Source code can be broken into as many or as few files as desired. When you use Visual Studio. NET, source files are listed in the Solution Explorer window, and all source is included from these files when the solution is built. When you are compiling from the command line, all source files must appear as command-line arguments to the compile command.

The location of declarations within source files is unimportant. As long as all referenced declarations appear somewhere in a source file being compiled, they will be found. Unlike previous versions of Visual Basic, no special file extensions are used to indicate various language constructs e. Syntax has been added to the language to differentiate various constructs. In addition, the pseudolanguage for specifying the graphical layout of forms has been removed.

Form layout is specified by setting properties of form objects explicitly within code. NET can write it. Namespace declarations may be declared either with identifiers or qualified identifiers.

Qualified identifiers consist of two or more identifiers connected with the dot character. Only namespace declarations may use qualified identifiers. Although Visual Basic. NET is not case sensitive, the case of identifiers is preserved when applications are compiled.

When using Visual Basic. NET components from case-sensitive languages, the caller must use the appropriate case. Ordinarily, identifiers may not match Visual Basic. NET keywords. If it is necessary to declare or use an identifier that matches a keyword, the identifier must be enclosed in square brackets []. Public is a keyword in Visual Basic. Escaping it with square brackets lets it be used as an identifier, in this case the name of a class. As a matter of style, using keywords as identifiers should be avoided, unless there is a compelling need.

This facility allows Visual Basic. NET applications to use external components that declare identifiers matching Visual Basic.

NET, keywords are reserved; that is, they cannot be used as tokens for such purposes as naming variables and subroutines. The keywords in Visual Basic. NET are shown in Table Table Next construct Else Used in the If End If construct Enum Visual Basic.

Next and For Each Next constructs Finally Visual Basic. Next construct Inherits Visual Basic. Next constructs Not Visual Basic. Next construct Stop Visual Basic. EndIf construct Throw Visual Basic. Next construct Variant Reserved but unused in Visual Basic. Finally construct While Used with the Do Loop and While End While constructs With Visual Basic. NET operator 2. The 10 in this code fragment is interpreted by the compiler as type Integer because it is an integer that falls within the range of the Integer type.

Integer literals that are outside the Integer range but are within the range of the Long type - through are interpreted as type Long. Integer literals outside the Long range cause a compile-time error. Numeric literals can also be of one of the floating point types—Single, Double, and Decimal. For example, in this line of code, 3. NET interprets floating point literals as type Double.

If the literal is outside the range of the Double type - 1. NET allows programmers to explicitly specify the types of literals. Table shown later in this chapter lists Visual Basic. NET's intrinsic data types, along with the method for explicitly defining a literal of each type. Note that for some intrinsic types, there is no way to write a literal.

For example, in the following line of code, "hello, world" is a literal of type String: Console. WriteLine "hello, world" String literals are not permitted to span multiple source lines.

In other words, this is not permitted: ' Wrong Console. WriteLine "hello, world" To write a string literal containing quotation-mark characters, type the character twice for each time it should appear. For example: Console. WriteLine "So then Dave said, ""hello, world"". NET's Char type represents a single character.

This is not the same as a one-character string; Strings and Chars are distinct types. Literals of type Char consist of a single character enclosed within quotation-mark characters, followed by the character c. They represent the true and false Boolean states, respectively of course! Nothing is a special symbol that represents an uninitialized value of any type.

It can be assigned to any variable and passed in any parameter. When used in place of a reference type, it represents a reference that does not reference any object. When used in place of a value type, it represents an empty value of that type. For numeric types, this is 0 or 0. For the String type, this is the empty string "". For the Boolean type, this is False. For the Char type, this is the Unicode character that has a numeric code of 0.

For programmer-defined value types, Nothing represents an instance of the type that has been created but has not been assigned a value. NET's intrinsic types, as well as the format for writing literals of those types in programs. However, this doesn't mean that literals cannot be used in situations where type Byte is expected. NET compiler considers to be of type Integer in this example, it recognizes that the number is small enough to fit into a variable of type Byte.

NET 2. NET are divided into two categories: value types and reference types. Value types minimize memory overhead and maximize speed of access, but they lack some features of a fully object-oriented design such as inheritance.

Reference types give full access to object-oriented features, but they impose some memory and speed overhead for managing and accessing objects. When a variable holds a value type, the data itself is stored in the variable.

When a variable holds a reference type, a reference to the data also known as a pointer is stored in the variable, and the data itself is stored somewhere else. NET's primitive types include both value types and reference types see "Fundamental Types" in this section. For extending the type system, Visual Basic.

NET provides syntax for defining both new value types and new reference types see "Custom Types" later in this section. All reference types derive from the Object type. To unify the type system, value types can be treated as reference types when needed. This means that all types can derive from the Object type. Treating value types as reference types a process known as boxing is addressed later in this chapter, in Section 2.

NET has several built-in types. Each of these types is an alias for a type supplied by the. NET architecture. Because Visual Basic. NET types are equivalent to the corresponding underlying.

NET-supplied types, there are no type-compatibility issues when passing arguments to components developed in other languages. In code, it makes no difference to the compiler whether types are specified using the keyword name for the type or using the underlying. NET type name. Int32 If x. GetType Is y. GetType Then Console.

WriteLine "They're the same type! WriteLine "They're not the same type. NET includes many logical operators that result in a Boolean type. The variable b is assigned the value True if the value in x is greater than the value in y and False if it is not. The underlying. NET type is System. Byte The Byte type can hold a range of integers from 0 through It represents the values that can be held in eight bits of data. The Char data type is new to Visual Basic. Date The Date type holds values that specify dates and times.

The range of values is from midnight on January 1, T through 1 second before midnight on December 31, T The Date type contains many members for accessing, comparing, and manipulating dates and times. Decimal The Decimal type holds decimal numbers with a precision of 28 significant decimal digits.

Its purpose is to represent and manipulate decimal numbers without the rounding errors of the Single and Double types. The Decimal type replaces Visual Basic 6's Currency type. The Double type holds floating point numbers in the range - 1. The smallest nonnegative number other than zero that can be held in a Double is 4. Integer The Integer type holds integers in the range through Long The Long type holds integers in the range through NET, Long is a bit integer data type.

Object The Object type is the base type from which all other types are derived. Short The Short type holds integers in the range through The Short data type corresponds to the VB 6 Integer data type.

The Single type holds floating point numbers in the range The smallest nonnegative number other than zero that can be held in a Double is 1. Object and String are reference types. NET provides rich syntax for extending the type system. Programmers can define both new value types and new reference types. Types declared with Visual Basic. NET's Structure and Enum statements are value types, as are all. NET Framework types that derive from System. Reference types include Object, String, all types declared with Visual Basic.

NET Framework types that don't derive from System. NET are similar to those in Visual Basic 6 and other languages. For example, here is a declaration of an Integer array that has five elements: Dim a 4 As Integer The literal 4 in this declaration specifies the upper bound of the array. All arrays in Visual Basic. NET have a lower bound of 0, so this is a declaration of an array with five elements, having indexes 0, 1, 2, 3, and 4.

The previous declaration is of a variable named a, which is of type "array of Integer. NET Framework's Array type defined in the System namespace and, therefore, have access to the methods defined in that type. GetLowerBound 0. ToString Console. GetUpperBound 0. ToString The output is: LowerBound is 0 UpperBound is 4 Note that the upper bound of the array is dynamic: it can be changed by methods available in the Array type.

Array elements are initialized to the default value of the element type. WriteLine a i Next Arrays can be multidimensional. Commas separate the dimensions of the array when used in declarations and when accessing elements. Here is the declaration of a three-dimensional array, where each dimension has a different size: Dim a 5, 10, 15 As Integer As with single-dimensional arrays, array elements are initialized to their default values.

The compiler infers the size from the number of elements in the initializer. To initialize multidimensional arrays, include the appropriate number of commas in the array-name declaration and use nested curly brackets in the initializer. Note also the meaning of this declaration by itself: Dim a As Integer This is the declaration of a reference that could point to a single-dimensional array of Integers, but doesn't yet. Its initial value is Nothing. Collections namespace. Interfaces are explained later in this chapter.

Briefly, an interface is an agreement in which the type will expose certain methods, properties, and other members. By exposing the ICollection interface, a type ensures that it can be used anywhere a collection is expected. In general, collections store multiple values and provide a way for iterating through those values.

Specialized collection types may also provide other means for adding and reading values. For example, the Stack type defined in the System. Collections namespace provides methods, such as Push and Pop, for performing operations that are appropriate for the stack data structure.

NET runtime provides a type called Collection defined in the Microsoft. VisualBasic namespace that mimics the behavior of Visual Basic 6 collections and exposes the ICollection interface. Example shows its use. Example Using the Collection type ' Create a new collection object. Dim col As New Collection ' Add some items to the collection.

Add "Some value" col. Add "Some other value" col. Add "A third value" ' Iterate through the collection and output the strings. Although strings are added to the collection in Example , the Add method is defined to take items of type Object, meaning that any type can be passed to the method. After items are added to the collection, they can be iterated using the For Each statement discussed later in this chapter, under Section 2.

Because the Collection class is defined to store items of type Object, the loop variable in the For Each statement must be of type Object. Because the items are actually strings, the code in Example converts the Object references to String references using the CType function. Type conversions are discussed later in this section. The Collection object has a Count property, which indicates the number of items in the collection.

Example is precisely the same as Example , except that it iterates through the Collection object using a numerical index and a standard For loop. Using a numerical index on a collection object ' Create a new collection object. Key An optional string value that can be used as an index to retrieve the associated item. For example, the following code adds an item to a collection and then uses the key value to retrieve the item: Dim col As New Collection col.

NET ' After The item after which the new item should be added. NET Framework class library provides several additional collection types, which are listed and briefly discussed in Chapter 3.

NET provides a variety of ways for values of one type to be converted to values of another type. There are two main categories of conversions: widening conversions and narrowing conversions. Widening conversions are conversions in which there is no possibility for data loss or incorrect results. For example, converting a value of type Integer to a value of type Long is a widening conversion because the Long type can accommodate every possible value of the Integer type.

Narrowing is the reverse operation—converting from a Long to an Integer—because some values of type Long can't be represented as values of type Integer. NET performs widening conversions automatically whenever necessary. For example, a widening conversion occurs in the second line of the following code. Whether the compiler permits this line of code depends on the value set for the Option Strict compiler option. When Option Strict is On, attempts to perform an implicit widening conversion result in a compiler error.

When Option Strict is Off, the compiler automatically adds code behind the scenes to perform the conversion. At runtime, if the actual value being converted is out of the range that can be represented by the target type, a runtime exception occurs. Option Strict can be set in either of two ways. First, it can be set in code at the top of a source file, like this: Option Strict On ' The other way is to set a compiler switch, which affects all source files in the application.

For example: vbc MySource. NET: 1. Right-click on the project name in the Solution Explorer window and choose Properties. This brings up the Project Property Pages dialog box. NET main menu to make it appear. Within that folder, choose the Build property page. This causes the project-build options to appear on the right side of the dialog box.

Set the desired value for the Option Strict option. By default, Option Strict is Off, meaning that implicit narrowing conversions are allowed.

This matches the default setting of Visual Basic 6. However, most experienced developers consider it beneficial to set Option Strict On so the compiler can help detect coding errors before they become runtime errors. Attempting to assign a Long to an Integer, for example, is usually a sign either that something was mistyped or that there is a problem with the design of the program. Setting Option Strict On helps the developer discover such errors at compile time.

On the other hand, there may sometimes be a legitimate need to perform a narrowing conversion. Perhaps the application is interfacing to another application that passes a value as a Long, but it is guaranteed that the actual value passed will never be outside the range of the Integer type.

Option Strict could be set to Off to allow implicit narrowing conversions, but a better alternative is to have Option Strict On so it can protect the majority of the program and to specify an explicit narrowing conversion.

If at runtime a contains a value that is outside the Integer range, an exception is thrown. Table shows Visual Basic. NET's conversion functions. If the argument can't be converted to the given type, an exception is thrown.

The case of the string is not important. It's also possible to convert between reference types. Any object-reference conversion of a derived type to a base type is considered a widening conversion and can therefore be done implicitly.

Conversely, conversion from a base type to a derived type is a narrowing conversion. As previously discussed, in order for narrowing conversions to compile, either Option Strict must be Off or an explicit conversion must be performed. Explicit conversions of reference types are done with the CType function. The CType function takes two arguments.

The first is a reference to some object, and the second is the name of the type to which the reference will convert. At runtime, if a conversion is possible, the return value of the function is an object reference of the appropriate type. If no conversion is possible, an exception is thrown. Here is an example of converting between base and derived classes: ' This is a base class. Public Class Animal ' End Class ' This is a derived class. Public Class Cat Inherits Animal ' End Class ' This is another derived class.

Public Class Dog Inherits Animal ' End Class ' This is a test class. In addition, programmers can define new types for use in their programs. Thanks a lot. Thanks man! Thanks ;. Thank you. Save me ton of time to find out good PDF for these books. Thanks alot. Wow okay I didn't realize this blew up from so many years ago lol. Thanks a million Yuan!! Thanks buddy. Thanks a lot..!! Links are dead Can you update them?

Set up a team. Enterprise Meet the needs of all learners with interactive learning, live online training courses, books, videos, and more. Get the information your employees need, from marketing and business leadership to technology.

Request a demo. Proven learning formats Our easy-to-follow, self-paced learning paths and interactive tutorials help users establish a knowledge base, build proficiencies, and develop new skills—their way.

Description 18 Hours of. Public Pastes. Arduino 17 min ago 0. Arduino 18 min ago 0. Arduino 19 min ago 0. Arduino 20 min ago 0.



0コメント

  • 1000 / 1000