- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
OTHER TOPICS in Visual C#.NET
CHAPTER 25 OTHER TOPICS Data Matrix ECC200 Creator In C# Using Barcode creator for VS .NET Control to generate, create Data Matrix 2d barcode image in .NET framework applications. www.OnBarcode.comScan Data Matrix ECC200 In C#.NET Using Barcode recognizer for .NET Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.comUsing Other XML Tags
EAN128 Creation In C# Using Barcode encoder for .NET framework Control to generate, create EAN / UCC - 14 image in Visual Studio .NET applications. www.OnBarcode.comPrinting Linear In C#.NET Using Barcode printer for Visual Studio .NET Control to generate, create Linear Barcode image in VS .NET applications. www.OnBarcode.comIn the preceding examples, you saw the use of the summary XML tag. There are also a number of other tags that C# recognizes. Table 25-3 lists some of the most important. Table 25-3. Documentation Code XML Tags Creating Code 128 In C#.NET Using Barcode drawer for Visual Studio .NET Control to generate, create Code 128B image in VS .NET applications. www.OnBarcode.comEAN13 Generator In C# Using Barcode drawer for VS .NET Control to generate, create European Article Number 13 image in VS .NET applications. www.OnBarcode.com<code> <example> <param> <remarks> <returns> <seealso> <summary> <value>
Matrix 2D Barcode Maker In C# Using Barcode maker for VS .NET Control to generate, create 2D Barcode image in VS .NET applications. www.OnBarcode.comUSPS OneCode Solution Barcode Generation In C# Using Barcode creator for .NET framework Control to generate, create USPS Intelligent Mail image in Visual Studio .NET applications. www.OnBarcode.comMeaning
DataMatrix Maker In None Using Barcode printer for Excel Control to generate, create Data Matrix image in Excel applications. www.OnBarcode.comData Matrix Drawer In None Using Barcode creation for Software Control to generate, create Data Matrix image in Software applications. www.OnBarcode.comFormat the enclosing lines in a font that looks like code. Mark the enclosing lines as an example. Mark a parameter for a method or constructor and allow a description. Describe a type declaration. Describe a return value. Create a See Also entry in the output document. Describe a type or a type member. Describe a property. Generate DataMatrix In Objective-C Using Barcode encoder for iPhone Control to generate, create ECC200 image in iPhone applications. www.OnBarcode.comCode 128A Drawer In Java Using Barcode printer for Android Control to generate, create Code 128 Code Set B image in Android applications. www.OnBarcode.comCHAPTER 25 OTHER TOPICS
Printing Code 39 Extended In Objective-C Using Barcode maker for iPhone Control to generate, create Code 3/9 image in iPhone applications. www.OnBarcode.comCreating USS Code 39 In Java Using Barcode generator for Java Control to generate, create Code39 image in Java applications. www.OnBarcode.comNested Types
EAN 13 Encoder In None Using Barcode drawer for Font Control to generate, create GTIN - 13 image in Font applications. www.OnBarcode.comEAN 13 Creation In Objective-C Using Barcode creator for iPad Control to generate, create EAN-13 Supplement 5 image in iPad applications. www.OnBarcode.comTypes are usually declared directly inside a namespace. You can, however, also declare types inside a class or struct declaration. Types declared inside another type declaration are called nested types. Like all type declarations, nested types are templates for an instance of the type. A nested type is declared like a member of the enclosing type. A nested type can be any type. An enclosing type can be either a class or a struct. Print UPC-A Supplement 5 In Java Using Barcode creator for BIRT reports Control to generate, create Universal Product Code version A image in BIRT reports applications. www.OnBarcode.comPDF 417 Reader In Visual C#.NET Using Barcode recognizer for .NET framework Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comFor example, the following code shows class MyClass, with a nested class called MyCounter. class MyClass { class MyCounter { ... } ... } // Enclosing class // Nested class GS1 128 Creation In Java Using Barcode creator for Java Control to generate, create GTIN - 128 image in Java applications. www.OnBarcode.comUPCA Encoder In Java Using Barcode creation for Java Control to generate, create UPC-A Supplement 5 image in Java applications. www.OnBarcode.comDeclaring a type as a nested type often makes sense if it s only meant to be used as a helper for the enclosing type. Don t be confused by the term nested. Nested refers to the location of the declaration not the location of any instances. Although a nested type s declaration is inside the enclosing type s declaration, objects of the nested type are not necessarily enclosed in objects of the enclosing type. Objects of the nested type if any are created at all are located wherever they would have been located had they not been declared inside another type. For example, Figure 25-6 shows objects of types MyClass and MyCounter, as outlined in the preceding code. The figure additionally shows a field called Counter, in class MyClass, that is a reference to an object of the nested class, which is located elsewhere in the heap. Figure 25-6. Nesting refers to the location of the declaration, not the location of the object.
CHAPTER 25 OTHER TOPICS
Example of a Nested Class
The following code fleshes out classes MyClass and MyCounter into a full program. MyCounter implements an integer counter that starts at 0 and can be incremented using the ++ operator. When the constructor for MyClass is called, it creates an instance of the nested class and assigns the reference to the field. Figure 25-7 illustrates the structure of the objects in the code. class MyClass { class MyCounter { private int _Count = 0; public int Count { get { return _Count; } } // Nested class // Read-only property
public static MyCounter operator++( MyCounter current ) { current._Count++; return current; } } private MyCounter counter; public MyClass() { counter = new MyCounter(); } public int Incr() { return (counter++).Count; } public int GetValue() { return counter.Count; } } class Program { static void Main( ) { MyClass mc = new MyClass(); mc.Incr(); mc.Incr(); mc.Incr(); mc.Incr(); mc.Incr(); mc.Incr(); Console.WriteLine("Total: } } {0}", mc.GetValue()); // Field of nested class // Constructor // Increment method // Get counter value // Create object // Increment it. // Increment it. // Print its value.
CHAPTER 25 OTHER TOPICS
This code produces the following output: Total: 6 Figure 25-7. Objects of a nested class and its enclosing class
Visibility and Nested Types
In 7, you learned that classes, and types in general, can have an access level of either public or internal. Nested types, however, are different in that they have member accessibility rather than type accessibility. Therefore, the following are true: A nested type declared inside a class can have any of the five class member accessibility levels public, protected, private, internal, or protected internal. A nested type declared inside a struct can have one of the three struct member accessibility levels public, internal, or private. In both cases, the default access level of a nested type is private, which means it cannot be seen outside the enclosing type. The relationship between the members of the enclosing class and the nested class is a little less straightforward and is illustrated in Figure 25-8. The nested type has complete access to the members of the enclosing type, regardless of their declared accessibility, including members that are private and protected. The relationship, however, is not symmetrical. Although the members of the enclosing type can always see the nested type declaration and create variables and instances of it, they do not have complete access to its members. Instead, their access is limited to the declared access of the nested class members just as if the nested type were a separate type. That is, they can access the public and internal members but cannot access the private or protected members of the nested type.
|
|