-4
Since MemberNames
is a string[]
and you want to retrieve the first value from it you can explicitly use index 0, provided that you check whether in fact the array has been initialized. Another option is the method FirstOrDefault()
, adding the reference of System.Linq
.
var _obj = "";
var memberNames = error.MemberNames;
//Pelo índice
_obj = (memberNames != null) ? memberNames[0] : "";
//Usando Linq
_obj = memberNames?.FirstOrDefault() ?? "";
After you edit your question, with your code is the class that is validating, I edit the question with a more complete answer.
Include the code in the question and not just a screenshot of your IDE
– Leandro Angelo