jeudi 10 mars 2016

How to get name of variable that was passed as parameter

Is it possible to get get name of variable that was passed as parameter?

I know I cant do it like that:

SetValue(Login, nameof(Login))

public void SetValue (IWebElement elemenet, string variableName)
{
element.SendKeys(variableName);
}

Expected result: Setting field: 'Login' with string 'Login'

But I would like to have something like:

SetValue(Login)

public void SetValue (IWebElement elemenet)
{
element.SendKeys(getNameOfVariableThatWasPassedByParameter(elemenet));
}

Expected result: Setting field: 'Login' with string 'Login'

Is it even possible with C#?





Aucun commentaire:

Enregistrer un commentaire