---
title: "How to call one constructor from the body of another in C#?"  
description: "How to call one constructor from the body of another in C#?"  
author: "Steilla Mitchel"  
published: 2023-08-18  
updated: 2023-08-19  
canonical: https://www.mindstick.com/forum/159571/how-to-call-one-constructor-from-the-body-of-another-in-c-sharp  
category: "c#"  
tags: ["c#", "class", "constructor"]  
reading_time: 1 minute  

---

# How to call one constructor from the body of another in C#?

How to call [one constructor](https://www.mindstick.com/forum/159570/how-to-call-one-constructor-from-another) from the [body](https://yourviews.mindstick.com/story/2120/rare-species-having-electricity-in-their-body) of another in C#?

## Replies

### Reply by Aryan Kumar

To call one constructor from the body of another in C#, you can use the `this()` keyword. The `this()` keyword refers to the current object.

The following code shows how to call one constructor from the body of another:

C#

```plaintext
class Person {
    public Person() {
        // This is the default constructor.
    }

    public Person(string name) {
        // This constructor takes a name parameter.
        this(); // Call the default constructor first.
        this.Name = name;
    }

    public string Name { get; set; }
}
```

In this example, the `Person()` constructor is the default constructor. The `Person(string name)` constructor takes a name parameter. The first line of the `Person(string name)` constructor calls the `Person()` constructor first. This is done to ensure that the fields of the `Person` class are initialized before the name property is set.


---

Original Source: https://www.mindstick.com/forum/159571/how-to-call-one-constructor-from-the-body-of-another-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
