Open In App
Related Articles

C# Program to Print the Current Assembly Name Using GetExecutingAssembly() Method

Improve Article
Improve
Save Article
Save
Like Article
Like

In C#, GetExecutingAssembly() method is the method of Assembly class. This method returns the assembly that contains the code that is currently executing. To use this method we have to use System.Reflection in our program.

Syntax:

public static System.Reflection.Assembly GetExecutingAssembly ();

It will return the current program assembly, version, culture, and PublicKeyToken. 

Example 1:

C#




// C# program to display the current assembly name 
using System;
using System.Reflection;
  
class GFG{
      
static void Main(string[] args)
{
    Console.WriteLine("Current assembly contains:");
    
    // Get the executing assembly
    // Using GetExecutingAssembly() method
    Console.WriteLine(Assembly.GetExecutingAssembly());
}
}


Output:

Current assembly contains:
main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

Example 2:

C#




// C# program to display the current assembly name 
using System;
using System.Reflection;
  
class GFG{
      
static void Main(string[] args)
{
      
    // Get the executing assembly 
    // with FullName property
    // FullName property is use 
    // to print the name of the assembly
    Console.WriteLine(Assembly.GetExecutingAssembly().FullName);
}
}


Output:

main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 16 Nov, 2021
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials