Environment.CommandLine Proprietà
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene la riga di comando per questo processo.
public:
static property System::String ^ CommandLine { System::String ^ get(); };
public static string CommandLine { get; }
static member CommandLine : string
Public Shared ReadOnly Property CommandLine As String
Stringa contenente gli argomenti della riga di comando.
Nell'esempio seguente viene visualizzata la propria riga di comando.
using namespace System;
int main()
{
Console::WriteLine();
// Invoke this sample with an arbitrary set of command line arguments.
Console::WriteLine( "CommandLine: {0}", Environment::CommandLine );
}
/*
The example displays output like the following:
C:\>env0 ARBITRARY TEXT
CommandLine: env0 ARBITRARY TEXT
*/
using System;
class Example
{
public static void Main()
{
Console.WriteLine();
// Invoke this sample with an arbitrary set of command line arguments.
Console.WriteLine("CommandLine: {0}", Environment.CommandLine);
}
}
// The example displays output like the following:
// C:\>env0 ARBITRARY TEXT
//
// CommandLine: env0 ARBITRARY TEXT
open System
// Invoke this sample with an arbitrary set of command line arguments.
printfn $"\nCommandLine: {Environment.CommandLine}"
// The example displays output like the following:
// C:\>env0 ARBITRARY TEXT
//
// CommandLine: env0 ARBITRARY TEXT
Class Example
Public Shared Sub Main()
Console.WriteLine()
' Invoke this sample with an arbitrary set of command line arguments.
Console.WriteLine("CommandLine: {0}", Environment.CommandLine)
End Sub
End Class
' The example displays output like the following:
' C:\>CommandLine ARBITRARY TEXT
'
' CommandLine: CommandLine ARBITRARY TEXT
Questa proprietà consente l'accesso al nome del programma e agli argomenti specificati nella riga di comando all'avvio del processo corrente.
Il nome del programma può includere informazioni sul percorso, ma non è necessario farlo. Usare il GetCommandLineArgs metodo per recuperare le informazioni della riga di comando analizzate e archiviate in una matrice di stringhe.
La dimensione massima del buffer della riga di comando non è impostata su un numero specifico di caratteri; varia a seconda del sistema operativo Windows in esecuzione nel computer.
Prodotto | Versioni |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: