Question: I have a class `Company`.

Inside my class i want to declare a string `LanguageCode` which gets is value from another class `Language`.

Like this:

```
public class Company : Entity  
{    
    public string LanguageCode
     {  
         get
         {
            Language l = new Language();              
            string language = l.Name;
            return language;
         }
         set { ;}
     }
}

```

When running I am not getting any error but is it correct way to create a new instance of a class in get {};

Answer: 
Properties should not have side effects. You normally don't create instances of other classes there and it makes not sense at all anyway in this case. If you need to execute a method to get the value you probably should use a method to return that value instead of a property. Properties should not be "expensive" and if they need to use another method they should be also a method imho.

I assume you store the name of the language in this class and you want to return the `Language` object according to this name:

```
public class Company : Entity
{
    public string LanguageName{ get;set; }

    public Language GetLanguage()
    {
        Language language = new Language(){ Name = this.LanguageName };
        return language;
    }
}

```
To start, as others have already suggested, if your set is empty then you are better off removing it to make the property clearly read-only.

Then, while it is formally correct, I do not see the logic in this getter. A new class is instantiated every time, and the return value is always the same.

If you just need to return the string with the Language name, you can declare a private property languageCode, initialize it in the constructor and then expose it with a public getter, like this:

```
public class Company : Entity  
{   
    private Language languageCode;

    public Company
    {
        languegeCode = new Language();
    }

    public string LanguageCode
    {  
        get
        {
            return languageCode.Name;
        }
    }
}

```