# Type

***

**1. Type Name Retrieval**

```csharp
Type type = typeof(int);
Console.WriteLine(type.Name); // Prints "Int32"
```

**2. Type Inheritance Check**

```csharp
bool isDerived = typeof(DerivedClass).IsSubclassOf(typeof(BaseClass));
```

**3. Type Reflection**

```csharp
Type type = typeof(Customer);
PropertyInfo propertyInfo = type.GetProperty("Name");
```

**4. Dynamic Object Creation**

```csharp
Type type = Type.GetType("System.String");
object value = Activator.CreateInstance(type, "Hello World");
```

**5. Array Creation**

```csharp
int[] array = (int[])Array.CreateInstance(typeof(int), 5);
```

**6. Type Conversion**

```csharp
object value = 10;
int convertedValue = (int)value;
```

**7. Attribute Retrieval**

```csharp
Type type = typeof(Customer);
Attribute attribute = type.GetCustomAttribute(typeof(SerializableAttribute));
```

**8. Interface Implementation Check**

```csharp
bool implementsInterface = typeof(Customer).GetInterface("ICustomer") != null;
```

**9. Method Invocation**

```csharp
object instance = new Customer();
Type type = instance.GetType();
MethodInfo methodInfo = type.GetMethod("GetName");
object result = methodInfo.Invoke(instance, null);
```

**10. Type Equality Check**

```csharp
bool areEqual = typeof(int) == typeof(int);
```

**11. Enum Value Representation**

```csharp
enum Days { Monday, Tuesday, Wednesday };
Type enumType = Days.Monday.GetType();
Console.WriteLine(enumType.UnderlyingSystemType); // Prints "System.Int32"
```

**12. Nullable Type Creation**

```csharp
Type nullableType = typeof(int?).GetGenericArguments()[0];
```

**13. Delegate Creation**

```csharp
Type delegateType = typeof(Func<int, int>);
```

**14. Generic Type Definition**

```csharp
Type genericType = typeof(List<>);
```

**15. Closed Generic Type Creation**

```csharp
Type closedGenericType = typeof(List<int>);
```

**16. Generic Type Parameter Retrieval**

```csharp
Type closedGenericType = typeof(List<int>);
Type[] genericArgs = closedGenericType.GetGenericArguments();
```

**17. Type Initialization**

```csharp
Type type = Type.GetType("System.Collections.Generic.List`1[System.Int32]");
object instance = Activator.CreateInstance(type);
```

**18. Typeof Operator**

```csharp
int value = 10;
Type type = typeof(value);
```

**19. typeof Keyword**

```csharp
Type type = typeof(int);
```

**20. GetType() Method**

```csharp
object instance = new Customer();
Type type = instance.GetType();
```

**21. Assembly.CreateInstance() Method**

```csharp
Assembly assembly = Assembly.Load("MyAssembly");
Type type = assembly.GetType("MyAssembly.MyType");
object instance = Activator.CreateInstance(type);
```

**22. GetTypeFromHandle() Method**

```csharp
RuntimeTypeHandle handle = typeof(int).TypeHandle;
Type type = Type.GetTypeFromHandle(handle);
```

**23. GetElementType() Method**

```csharp
Type type = typeof(int[]);
Type elementType = type.GetElementType(); // Returns "System.Int32"
```

**24. GetInterfaces() Method**

```csharp
Type type = typeof(Customer);
Type[] interfaces = type.GetInterfaces();
```

**25. GetCustomAttributes() Method**

```csharp
Type type = typeof(Customer);
Attribute[] attributes = type.GetCustomAttributes(true);
```

**26. CreateDelegate() Method**

```csharp
Type type = typeof(Func<int, int>);
object instance = new Customer();
MethodInfo methodInfo = type.GetMethod("GetName");
Delegate delegateInstance = Delegate.CreateDelegate(type, instance, methodInfo);
```

**27. MakeArrayType() Method**

```csharp
Type type = Type.GetType("System.Int32");
Type arrayType = type.MakeArrayType(1); // Creates a one-dimensional array type
```

**28. GetGenericTypeDefinition() Method**

```csharp
Type type = typeof(List<int>);
Type genericTypeDefinition = type.GetGenericTypeDefinition(); // Returns "System.Collections.Generic.List`1"
```

**29. GetGenericArguments() Method**

```csharp
Type type = typeof(List<int>);
Type[] genericArgs = type.GetGenericArguments(); // Returns "System.Int32"
```

**30. MakeGenericType() Method**

```csharp
Type genericTypeDefinition = typeof(List<>);
Type closedGenericType = genericTypeDefinition.MakeGenericType(typeof(int)); // Creates "System.Collections.Generic.List`1[System.Int32]"
```

**31. IsAssignableFrom() Method**

```csharp
Type baseType = typeof(BaseClass);
Type derivedType = typeof(DerivedClass);
bool isAssignableFrom = baseType.IsAssignableFrom(derivedType);
```

**32. IsAbstract() Property**

```csharp
Type type = typeof(AbstractClass);
bool isAbstract = type.IsAbstract;
```

**33. IsSealed() Property**

```csharp
Type type = typeof(SealedClass);
bool isSealed = type.IsSealed;
```

**34. IsClass() Property**

```csharp
Type type = typeof(Class);
bool isClass = type.IsClass;
```

**35. IsInterface() Property**

```csharp
Type type = typeof(IInterface);
bool isInterface = type.IsInterface;
```

**36. IsValueType() Property**

```csharp
Type type = typeof(ValueType);
bool isValueType = type.IsValueType;
```

**37. IsEnum() Property**

```csharp
Type type = typeof(Days);
bool isEnum = type.IsEnum;
```

**38. IsGenericType() Property**

```csharp
Type type = typeof(List<int>);
bool isGenericType = type.IsGenericType;
```

**39. IsGenericTypeDefinition() Property**

```csharp
Type type = typeof(List<>);
bool isGenericTypeDefinition = type.IsGenericTypeDefinition;
```

**40. IsGenericParameter() Property**

```csharp
Type type = Type.GetType("T");
bool isGenericParameter = type.IsGenericParameter;
```

**41. GetGenericParameterConstraints() Method**

```csharp
Type type = Type.GetType("T");
Type[] constraints = type.GetGenericParameterConstraints();
```

**42. GetNestedTypes() Method**

```csharp
Type type = typeof(OuterClass);
Type[] nestedTypes = type.GetNestedTypes();
```

**43. GetAssembly() Method**

```csharp
Type type = typeof(Customer);
Assembly assembly = type.Assembly;
```

**44. GetModule() Method**

```csharp
Type type = typeof(Customer);
Module module = type.Module;
```

**45. GetNamespace() Method**

```csharp
Type type = typeof(Customer);
string @namespace = type.Namespace;
```

**46. GetFullName() Method**

```csharp
Type type = typeof(Customer);
string fullName = type.FullName;
```

**47. GetGUID() Method**

```csharp
Type type = typeof(Customer);
Guid guid = type.GUID;
```

**48. GetCustomAttributes(Type, bool) Method**

```csharp
Type type = typeof(Customer);
Attribute[] attributes = type.GetCustomAttributes(typeof(SerializableAttribute), true);
```

**49. ToString() Method**

```csharp
Type type = typeof(Customer);
string typeName = type.ToString();
```

**50. GetHashCode() Method**

```csharp
Type type = typeof(Customer);
int hashCode = type.GetHashCode();
```
