• Source
    1. using System;
    2. using System.Reflection;
    3.  
    4. public class Test
    5. {
    6. public static void Main()
    7. {
    8. Assembly assembly = Assembly.GetExecutingAssembly();
    9.  
    10. Console.WriteLine("\nEvidence: " + assembly.Evidence);
    11.  
    12. Console.WriteLine("\nEntry point: " + assembly.EntryPoint);
    13.  
    14. Console.WriteLine("\nIs in GAC: " + assembly.GlobalAssemblyCache);
    15.  
    16. Console.WriteLine("\nHostContext: " + assembly.HostContext);
    17.  
    18. Console.WriteLine("\nImage Runtime Version: " + assembly.ImageRuntimeVersion);
    19.  
    20. Console.WriteLine("\nUNC location: " + assembly.Location);
    21.  
    22. Console.WriteLine("\nGets module containing manifest for current assembly: " + assembly.ManifestModule);
    23.  
    24. Console.WriteLine("\nIf loaded into the reflection-only context: " + assembly.ReflectionOnly);
    25.  
    26. // // Is not compiled by ideone.com, possible coz it's using Mono
    27.  
    28. // Console.WriteLine("\nWas generated dynamically by reflection emit: " + assembly.IsDynamic);
    29. // // Was generated dynamically by reflection emit: False
    30.  
    31. // Console.WriteLine("\nIs loaded with full trust: " + assembly.IsFullyTrusted);
    32. // // Is loaded with full trust: True
    33.  
    34. // Console.WriteLine("\nGrant set of current assembly: " + assembly.PermissionSet);
    35. // // Grant set of current assembly: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" />
    36.  
    37. // Console.WriteLine("\nSet of security rules which was enforced by CLR: " + assembly.SecurityRuleSet);
    38. // // Set of security rules which was enforced by CLR: Level2
    39.  
    40. foreach (var atr in assembly.GetCustomAttributes(true))
    41. {
    42. Console.WriteLine(atr.ToString());
    43. }
    44. // // System.Runtime.CompilerServices.RuntimeCompatibilityAttribute
    45. }
    46. }
    47.  
    48. public class SomeClass
    49. {
    50. string field;
    51.  
    52. public SomeClass()
    53. {
    54. field = "firld value";
    55. }
    56.  
    57. public void Method()
    58. {
    59. if(String.IsNullOrEmpty(field))
    60. {
    61. Console.WriteLine("Field '" + field + "' is not null");
    62. }
    63. else
    64. {
    65. Console.WriteLine("Field is null");
    66. }
    67. }
    68. }