We know that Record types which have been introduced in C# 9.0. see the code and tell me what is difference between these two set of code ?
i found one article said about Record as follow
1) Immutable means it cannot change. By default, Record types are immutable.
2) Record Type - it is a compact and easy way to write reference types (immutable) that automatically behave like value type
why people saying record behave like value type....what does it mean?
public class Member
{
public int ID { get; init; }
public string FirstName { get; init; }
public string LastName { get; init; }
public string Address { get; init; }
}
and
public record Member
{
public int ID { get; init; }
public string FirstName { get; init; }
public string LastName { get; init; }
public string Address { get; init; }
}
the only difference is Record keyword used in 2nd code. other than this what is difference ?
**1) please discuss with some sample code which i can run and understand the difference & usage.
2) when to use record type....please discuss a scenario.**
thanks