-3
namespace BrowserCompatabilityTests
{
    public static class Selectors
    {
        public static string activateDeviceButton = "#root > div > div > div > 
        div.row.activate--full-page > div:nth-child(2) > form > 
        div.form__actions.flex > button";
    }
}

I was asked to update this activateDevice field to a readonly getter property. Is there a C# convention to use {get,set} or lambda?

3 Answers3

3

Try this variant, this sets the property value exactly once.

public static string activateDeviceButton { get; } = "#root > div > div > div > div.row.activate--full-page > div:nth-child(2) > form > div.form__actions.flex > button";
samtrion
  • 111
  • 6
2

Look into getter and setter properties. Here is how it would potentially look:

public static string activateDeviceButton { get {return value;}}
samtrion
  • 111
  • 6
Chris
  • 46
  • 4
0

You may declare ReadOnly properties either with a get (without set):

public string activateDeviceButton { get{ return someValue;} }

Or with a Lambda Expression:

   public string activateDeviceButton => someValue;
Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171