Author - Amatya Agyey Tech Lead - Motherson What is the difference between a class and a struct in C#? Answer: A class is a reference type, while a struct is a value type. Objects of a class are allocated on the heap, whereas struct instances are allocated on the stack. Explain the difference between a shallow copy and a deep copy. Answer: A shallow copy creates a new reference to the same memory location, while a deep copy creates a new copy of the entire object and its referenced objects. What are the access modifiers available in C#? Answer: C# provides five access modifiers: public, private, protected, internal, and protected internal. How do you handle exceptions in C#? Answer: Exceptions can be handled using try-catch-finally blocks. The try block contains the code that may throw an exception, and the catch block catches and handles the exception. The finally block is used to execute code that should always run, regardless of whether an exception occurred or not. What is the
Author - Amatya Agyey Tech Lead- Motherson What is the difference between a class and a struct in C#? Answer: A class is a reference type, while a struct is a value type. Objects of a class are allocated on the heap, whereas struct instances are allocated on the stack. Explain the difference between a shallow copy and a deep copy. Answer: A shallow copy creates a new reference to the same memory location, while a deep copy creates a new copy of the entire object and its referenced objects. What are the access modifiers available in C#? Answer: C# provides five access modifiers: public, private, protected, internal, and protected internal. How do you handle exceptions in C#? Answer: Exceptions can be handled using try-catch-finally blocks. The try block contains the code that may throw an exception, and the catch block catches and handles the exception. The finally block is used to execute code that should always run, regardless of whether an exception occurred or not. What is the purp