Environment.MachineName Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém o nome NetBIOS deste computador local.
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
Valor de Propriedade
O nome deste computador.
Exceções
O nome deste computador não pode ser obtido.
Exemplos
O exemplo seguinte mostra o nome do computador que executa o exemplo de código. (O nome da máquina é omitido na saída de exemplo por razões de segurança.)
// 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---!
'
Observações
O nome deste computador é estabelecido no arranque do sistema, quando o nome é lido do registo. Se este computador for um nó num cluster, o nome do nó é devolvido.