Câu hỏi phỏng vấn C#
Câu hỏi

What are Reference Types in C#?

Câu trả lời

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#:

1. Classes

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();

2. Interfaces

Interfaces are also reference types. Variables of an interface type can hold references to objects that implement that interface.

IMyInterface obj = new MyClass();

3. Delegates

Delegates are reference types that represent methods with a specific signature. They are used for event handling and callbacks.

EventHandler obj = MyMethod;

4. Arrays

Arrays are reference types, even i...

junior

junior

Gợi ý câu hỏi phỏng vấn

senior

What is scope of a Protected Internal member variable of a C# class?

middle

What is the difference between Equality Operator ( == ) and Equals() Method in C#?

middle

What is the use of the IDisposable interface?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào