|
| |
| 19. 1. 10. Get BaseType, Name, FullName and Namespace for a type |
|
|
|
using System;
class MainClass
{
static void Main(string[] args)
{
Object cls1 = new Object();
System.String cls2 = "Test String" ;
Type type1 = cls1.GetType();
Type type2 = cls2.GetType();
// Object class output
Console.WriteLine(type1.BaseType);
Console.WriteLine(type1.Name);
Console.WriteLine(type1.FullName);
Console.WriteLine(type1.Namespace);
// string output
Console.WriteLine(type2.BaseType);
Console.WriteLine(type2.Name);
Console.WriteLine(type2.FullName);
Console.WriteLine(type2.Namespace);
}
}
|
|
Object
System.Object
System
System.Object
String
System.String
System
|
| 19. 1. Type | | 19. 1. 1. | Reflection | | | | 19. 1. 2. | type identity | | | | 19. 1. 3. | Commonly used methods defined by Type: | | | | 19. 1. 4. | A second form of GetMethods() lets you specify various flags that filter the methods that are retrieved. | | | | 19. 1. 5. | Obtain type information using the Type.GetType method(Case sensitive, return null if not found). | | | | 19. 1. 6. | Obtain type information using the Type.GetType method(Case sensitive, throw TypeLoadException if not found) | | | | 19. 1. 7. | Obtain type information using the Type.GetType method(Case insensitive, throw TypeLoadException if not found) | | | | 19. 1. 8. | Obtain type information using the Object.GetType method | | | | 19. 1. 9. | Is object a type | | | | 19. 1. 10. | Get BaseType, Name, FullName and Namespace for a type | | | | 19. 1. 11. | Type: FullName, BaseType, IsAbstract, IsCOMObject, IsSealed, IsClass | | | | 19. 1. 12. | Get the Type representation: object | | | | 19. 1. 13. | Obtain the handles: object | | | | 19. 1. 14. | Get all methods from a Type | | | | 19. 1. 15. | Open and constructed generic types | | | | 19. 1. 16. | Getting generic type definition information | | | | 19. 1. 17. | Dynamically constructing types | | | | 19. 1. 18. | Create StringBuilder | | |
|