What are Reference Types in C#?
What are Reference Types in C#?
In C#, reference types are variables that store references to objects in memory. When you create an instance of a reference type, the variable holds a reference to the object's location in memory rather than the object itself. Here are the key points about reference types in C#:
Classes are the most common reference types in C#. When you create an instance of a class using the new
keyword, a reference to the object is stored in the variable.
MyClass obj = new MyClass();
Interfaces are also reference types. Variables of an interface type can hold references to objects that implement that interface.
IMyInterface obj = new MyClass();
Delegates are reference types that represent methods with a specific signature. They are used for event handling and callbacks.
EventHandler obj = MyMethod;
Arrays are reference types, even i...
junior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào