What is the method Me...
What is the method Me...
The MemberwiseClone()
method in C# creates a shallow copy of the current object. Here's what it does:
In other words, MemberwiseClone()
creates a new object with the same field values as the original object, but it does not create new copies of the referenced objects. This means that if the original object has reference type fields, both the original object and the cloned object will reference the same objects.
Here's an example:
class Person
{
public string Name { get; set; }
public Address Address { get; set; }
}
class Address
{
public string Street { get; set; }
public string City { get; set; }
}
static void Main(string[] args)
{
Person person1 = new Person
{
Name = "John Doe",
Address = new Ad...
expert
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào