record
objects that rely on const
parameters CS-P1022Records are structures that are extensively used in serialization and deserialization. However, if your instance of record
takes in parameters that are class' const
fields, consider reusing the same record
instance instead of instantiating a new one.
public void M()
{
var issue = new Issue(code, offset); // Both `code` and `offset` are `const` fields
Publish(issue);
}
private readonly Issue issue = new(code, offset);
public void M()
{
Publish(issue);
}