C# Console Application Versions

Well, something stumped me. But figured it out … As part of my C# console application, I wanted to print out the version (Major.Minor.Revision) as part of the help output so I could know the release details. And without the Application object, I just wanted the simple information from the build assembly.

C# Code

Version vrs = Environment.Version;
Console.Write("Version: {0}.{1}.{2}"
, vrs.Major, vrs.Minor, vrs.Revision);

Nice. Hope that helps you too, cause it took a little bit to sift through a lot of “mud blog” to find it.

3 Responses

  1. Environment.Version is the version of the .NET framework.
    This did not help me.

  2. you need something like this

    Assembly assembly = Assembly.GetAssembly(Type.GetType(“Mynamespace.Program”));
    Version vrs = assembly.GetName().Version;

  3. this method gives you Framework version. not console applications version

Leave a Reply