I have a file and i can get 2 lines in the file.I have a file with the following content.
public class Websites
{
//private const string URL = "https://au.yahoo.com/?p=us";
private const string URL = "https://www.google.com/";
//private const string URL = "https://stackoverflow.com/";
....
I can get the 2 lines individually like so:
$linegoogle = Get-Content "C:\myfile.cs" | Select-String "https://www.google.com/" | Select-Object -
ExpandProperty Line
$google = $linegoogle.Trim()
$linestackoverflow = Get-Content "C:\myfile.cs" | Select-String "https://stackoverflow.com/" |
Select-Object -ExpandProperty Line
$stackoverflow = $linestackoverflow.Trim()
But what i wabn to do is the following:
if (condition1)
{
//replace the 2 lines with
// private const string URL = "https://www.google.com/";
private const string URL = "https://stackoverflow.com/";
}
else if (condition 2)
{
//replace the 2 lines with
private const string URL = "https://www.google.com/";
// private const string URL = "https://stackoverflow.com/";
}