HOW TO GET MACHINE NAME IN C#

lois waisbrooker

Total Post:70

Points:494
Posted by  lois waisbrooker
C# 
C#
 1466  View(s)
Ratings:
Rate this:
Hi Developers,

I want to get machine name (e.g. my PC name is "compter-1") using C# line of code.
Please provide line of code or any useful link!

Thanks in advance. 
  1. Vijay Shukla

    Post:100

    Points:700
    Re: how to get machine name in c#

    Hi lois waisbrooker!
    below line of code show your machine name (PC-name) .
    class MachineName
        {
            static void Main(string[] args)
            {
                Console.WriteLine(Environment.MachineName);
                Console.ReadKey();
            }
        }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!