I have a C# script and I want to use some of the variables I’ve declared in a cmd command:
using System;
using System.Diagnostics;
namespace UserMake
{
class Program
{
static void Main(string[] args)
{
string userName;
string passWord;
Console.WriteLine("Enter a username:");
userName = Console.ReadLine();
Console.WriteLine("Enter a password:");
passWord = Console.ReadLine();
Process.Start("cmd","net user userName passWord /add");
}
}
}
I can’t work out how to get the ‘userName’ and ‘passWord’ to read as the variable set rather than making a user called ‘userName’ with password ‘passWord’.
Any help is appreciated.
Use string concatenation:
Alternatively, you could use
string.Format: