
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are circular references in C#?
Circular reference occurs when two or more interdependent resources cause lock condition. This makes the resource unusable.
To handle the problem of circular references in C#, you should use garbage collection. It detects and collects circular references. The garbage collector begins with local and static and it marks each object that can be reached through their children.
Through this, you can handle the issues with circular references.
Let’s say the following classes is in circular reference. Here both of them depends on each other −
public class A { B Two; } public class B { A one; }
To solve the issue, create an interface −
public interface myInterface { } public class A { myInterface Two; } public class B: myInterface { A one; }
- Related Articles
- Circular References in Perl
- What are method references in Java8?
- How can circular references cause memory leakage in JavaScript?
- What are the method references in Java?
- What are the constructor references in Java?
- References in C++
- Pointers vs References in C++
- How to use Interface References in C#?
- When to use references vs. pointers in C/C++
- C/C++ Pointers vs Java references\n
- Examples of soft references and phantom references?
- References are not allowed in a SAP remote function call
- Create References in Perl
- PHP References
- References to Functions in Perl

Advertisements