public class Potato
{
int SomeID { get; set; }
DataTable Potable { get; set; }
[Key]
string PotatoKey { get; set; }
object GrimReaper { get; set; }
}
When comparing 2 potatoes, does having a [Key] attribute tell C# that in order to do the comparison only PotatoKey has to be compared? Or do I still need to explicitly tell to compare PotatoKeys?
[Key]
does literally nothing by itself; it requires other code (usually library code) to check that it exists, and infer some special meaning - presumably "treat this as a primary key" when being handled by some ORM. It doesn't change anything about the C# compiler or any part of the .NET runtime except those parts that explicitly check for it. It does not change how object equality or comparison works, for example. There are only a very small handful of attributes that directly impact how code behaves.