Visual Studioでデバッグ時に、コマンドライン引数を指定する方法はこちらの記事を参照してください。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommandLineArgsString
{
class Program
{
static void Main(string[] args)
{
string CommandStr = System.Environment.CommandLine;
Console.WriteLine("CommandLine : {0}", CommandStr);
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CommandLineArgsWinForm
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
private void FormMain_Load(object sender, EventArgs e)
{
string CommandStr = System.Environment.CommandLine;
textBox1.Text = CommandStr;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplicationParameter
{
class Program
{
static void Main(string[] args)
{
string[] Commands = System.Environment.GetCommandLineArgs();
for (int i = 0; i < Commands.Length; i++) {
Console.WriteLine("command : {0:d} : {1}\r\n", i, Commands[i]);
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CommandLineArgsWinForm
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
private void FormMain_Load(object sender, EventArgs e)
{
string[] Commands = System.Environment.GetCommandLineArgs();
for (int i = 0; i < Commands.Length; i++) {
textBox1.Text += string.Format("command : {0:d} : {1}\r\n", i, Commands[i]);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommandLineArgsMain
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < args.Length; i++) {
Console.WriteLine("command : {0:d} : {1}\r\n", i, args[i]);
}
Console.ReadLine();
}
}
}