IntroductionToday I would like to share with another great new feature in .NET Framework 4.0, the new features is how do we decide the current Operating System and Process version is 32 or 64 bits. How to get the Operating System 32 or 64 bits- Environment.Is64BitOperatingSystem
Determines whether the current operating system is a 64-bit operating system How to use using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;using System.Data;namespace ConsoleApplication1
{class Program{static void Main(string[] args){if (Environment.Is64BitOperatingSystem){Console.WriteLine("This is 64 bit operating system");}else{Console.WriteLine("This is 32 bit operating system");}Console.ReadLine();}}} Output This is 64 bit operating system Note:I have run above code in windows 2003 Server. How to know Process Bits- Environment.Is64BitProcess
Determines whether the current process is a 64-bit process. How to use using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;using System.Data;namespace ConsoleApplication1
{class Program{static void Main(string[] args){if (Environment.Is64BitProcess){Console.WriteLine("This is 64 bit Process");}else{Console.WriteLine("This is 32 bit Process");}Console.ReadLine();}}} Output This is 64 bit Process Note:I have run above code in windows 2003 server. How to ternimate application with write log in event logThis method help to developers,Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and exception information in error reporting to Microsoft. How to use using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;using System.Data;namespace ConsoleApplication1
{class Program{static void Main(string[] args){string causeOfFailure = "The unknown failure";try{Environment.FailFast(causeOfFailure);}finally{Console.WriteLine("This finally block will not be executed.");}}}} I hope this is help to you all, i will publish another tips about new features in .NET 4.0 soon. |