This cannot be done because once the class definition is set, that’s it.
The best you can do to retrieve an array of only the Name
and Address
properties contained in an object is to use LINQ
to perform an operation on each element, in which case you can then retrieve an array of anonymous types specifying exactly the properties you want.
example:
var result = (from e in lstEmployee
select new { e.Name, e.Address }).ToArray();
6
solved Delete object single property from list