Before examining the data types in C#, it is important to understand that C# distinguishes between two categories of data type:
Value types
Reference types
The next few sections look in detail at the syntax for value and reference types. Conceptually, the difference is that a value type stores its value directly, whereas a reference type stores a reference to the value. Compared to other languages, value types in C# are basically the same thing as simple types (integer, float, but not pointers or references) in Visual Basic or C++. Reference types are the same as reference types in Visual Basic, or ar
|
标签:杂谈 |
As indicated earlier, all .NET classes are ultimately derived from System.Object. In fact, if you don't specify a base class when you define a class, the compiler will automatically assume that it derives from Object. Because inheritance has not been used in this chapter, every class you have seen here is actually derived from System.Object. (As noted earlier, for structs this derivation is indirect: A struct is always derived from System.ValueType, which in turn derives from System.Object.)
The practical significance of this is that, besides the methods and properties and so on that you define, you also have access to a number of public and protected member methods that have been define
Delegates exist for situations in which you want to pass methods around to other methods. To see what that means, consider this line of code:
int i = int.Parse('99');
You are so used to passing data to methods as parameters, as in this example, you don't consciously think about it; and for this reason the idea of passing methods around instead of data might sound a little strange. However, there are cases in which you have a method that does something, and rather than operating on data, the method might need to do something that involves invoking another method. To complicate things further,
|
标签:留学 |
分类:PREPARATION FOR IELTS |
| |
Adjec |
|
标签:ielts |
分类:PREPARATION FOR IELTS |