Skip to main content

Explore the Use of System.Environment Class

System.Environment class can not be inherited. It provides valuable information about current platform and environment of the system.
It uses to retrieve environment variable settings, version of the CLR and call stack contents etc.

It has various methods and property to get the useful information about current working environment. Lets have a look on some of most used properties.

Get the Machine Name
– To Get the current system’s machine name we can use MachineName property of Environment class.

For example :
Console.WriteLine(“Machine Name :” + Environment.MachineName);

Get the Current Working Directory
– To Get the current working directory we can use CurrentDirectory property of Environment class.

For example :
Console.WriteLine(“Current Directory :” + Environment.CurrentDirectory);

Get the Current UserName of the system
– To Get the current user name we can use UserName property of the Environment class.

For example :
Console.WriteLine(“User Name :” + Environment.UserName);
Get the current Operating System Version ?
– To Get teh current OS Version we can use OSVersion property of the Environment class.

For example :
Console.WriteLine(“OS Version :” + Environment.OSVersion);

See the below Full C# code.

using System;

namespace SystemEnv
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Line 1");
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Line 2");
            Console.WriteLine("Machine Name :" + Environment.MachineName);
            Console.WriteLine("Current Directory :" + Environment.CurrentDirectory);
            Console.WriteLine("OS Version :" + Environment.OSVersion);
            Console.WriteLine("User Name :" + Environment.UserName);
            Console.Read();
        }
    }
}

What is the Difference between Build, Rebuild and Clean in Visual Studio?

If you are a Microsoft Asp.Net Developer then usually you came across this words like Build, Rebuild and Clean.

This article gives you explanation about Difference between Build, Rebuild and Clean


If you are using Visual studio you might have question that what is difference between Build, Rebuild and Clean ? here we are going to understand the diversity between them.

Build Solution :
When we build any solution then Visual studio will build/compile all assemblies (Dlls and EXE’s) that are changed, it is basically incremental or partial process in which only CHANGED assemblies are compiled if there is no changed assemblies it won’t get build

Rebuild Solution:
It is full compiled case, in which all assemblies (either changed or not) are deleted and recompiled again, irrespective of changed or not

Clean Solution:
It is not compile case, it just delete all assemblies (Dlls and EXE’s) from folder but not compiled them again, it remove all compiled files from previous build

Hope you understand this simple article

Difference between .Net DLL and Normal DLL file

DLL is stands for Dynamic Link Library. DLL is a file format which holds multiple codes and procedures for windows applications. Generally DLL files are created so that multiple application can use it at the same time. It has common code which may be used by multiple programs so it can reduce the disk space, load faster and consume less memory. DLLs can be converted to static libraries by using MSIL (Microsoft Intermediate Language) diassempler. It is very similar to .EXE file but it can not be execute directly like EXE, but holds same information like code, data and resources.

What is .NET dll file?

When we create a .NET DLL or Assemply in .Net Languages like VB.Net or C#.Net it will create a Managed Assembly. Managed Assembly is the component standard specified by Microsoft .Net. So .Net DLL (assemblies) are only understandable by Microsoft.Net Framework and can be used only in Microsoft.Net managed applications. A managed assemly contains managed code only and it can be executed by .Net Runtime. While when we are creating a C++ DLL then it will generated a win32 com DLL. So if we want to use that DLL in out .Net application the Visual Studio will automatically creates an INTEROP for that to call unmanaged dll from managed code.

We if want to use .NET DLL files into our application then we need to copy the DLL file into BIN folder or add a reference for that DLL file.

What is a Normal DLL file?

Normal DLL file contians code that we can use in our application or program. That code can be written as a separete modules (common functions) so other application or module can use it. Other application is may be .EXE file or .DLL file. It is like a libraries which can holds code, data or resources and can be used by multiple application at the same time. It will help us to modulirse our code, reuse the code, we can do more efficent memoty usage. If we are using common DLL for multiple application then it will consume less disk space and also load faster into memory.

We if want to use Normal DLL files into our application then we need to register it first using the “regsvg32” command or tool.

MIME for DLL files is : application/x-msdownload