В приведенном ниже примере я присвоил имя «CustomerType» свойству x.Preferred.
Помимо возможного улучшения читаемости, есть ли какие-либо преимущества / недостатки в производительности при назначении имени свойству?
using System;
using System.Linq;
namespace ConsoleApp2
{
public class Customer
{
public string Name { get; set; }
public string ID { get; set; }
public string Preferred { get; set; }
// Constructor that takes one argument:
public Customer(string _name, string _iD, string _preferred)
{
Name = _name;
ID = _iD;
Preferred = _preferred;
}
static void Main(string[] args)
{
Customer[] cust = new Customer[]
{
new Customer ("Mike", "1234", "Preferred"),
new Customer ("Alice", "4321", "Preferred"),
new Customer ("Susan", "3214", "Not Preferred"),
new Customer ("David", "7538", "Preferred")
};
var customers = cust
.Where(x => x.Preferred == "Not Preferred")
.Select(x => new
{
x.Name,
x.ID,
CustomerType = x.Preferred // What are the advantages/disavantages of assigning the name "CustomerType" to this property?
});
foreach (var customer in customers)
{
Console.WriteLine($" Preferred Customer is {customer.Name}. Customer ID is {customer.ID}. Customer is {customer.CustomerType}.\n ");
}
}
}
}