Environment.MachineName Proprietà

Definizione

Ottiene il nome NetBIOS del computer locale.

public:
 static property System::String ^ MachineName { System::String ^ get(); };
public static string MachineName { get; }
static member MachineName : string
Public Shared ReadOnly Property MachineName As String

Valore della proprietà

Nome del computer.

Eccezioni

Impossibile ottenere il nome del computer.

Esempio

Nell'esempio seguente viene visualizzato il nome del computer che esegue l'esempio di codice. Il nome del computer viene omesso dall'output di esempio per motivi di sicurezza.

// Sample for the Environment.MachineName property
using System;

class Sample
{
    public static void Main()
    {
    Console.WriteLine();
//  <-- Keep this information secure! -->
    Console.WriteLine("MachineName: {0}", Environment.MachineName);
    }
}
/*
This example produces the following results:
(Any result that is lengthy, specific to the machine on which this sample was tested, or reveals information that should remain secure, has been omitted and marked "!---OMITTED---!".)

MachineName: !---OMITTED---!
*/
// Sample for the Environment.MachineName property
open System

//  <-- Keep this information secure! -->
printfn $"\nMachineName: {Environment.MachineName}"

// This example produces the following results:
//     (Any result that is lengthy, specific to the machine on which this sample was tested, or reveals information that should remain secure, has been omitted and marked "!---OMITTED---!".)
//
//     MachineName: !---OMITTED---!
' Sample for the Environment.MachineName property
Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      '  <-- Keep this information secure! -->
      Console.WriteLine("MachineName: {0}", Environment.MachineName)
   End Sub
End Class
'
'This example produces the following results:
'(Any result that is lengthy, specific to the machine on which this sample was tested, 
'or reveals information that should remain secure, has been omitted 
'and marked "!---OMITTED---!".)
'
'MachineName: !---OMITTED---!
'

Commenti

Il nome del computer viene stabilito all'avvio del sistema quando il nome viene letto dal Registro di sistema. Se il computer è un nodo in un cluster, viene restituito il nome del nodo.

Si applica a