Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is internal set property in c#?

Tags:

c#

I just came across an unknown concept of c# for me. Can anyone tell me what the purpose of an internal set property is? What is its use? I know internal keyword is used for working within an assembly.

like image 314
Amit Soni Avatar asked Aug 25 '11 09:08

Amit Soni


People also ask

What are internal properties?

Physical property can be divided into two categories: what I call external property, which refers to material objects of some value situated outside anatomical human bodily confines (such as clothing, houses or land), and internal property, which refers to native human body parts.

What is internal in C?

The internal keyword is an access modifier for types and type members. This page covers internal access. The internal keyword is also part of the protected internal access modifier. Internal types or members are accessible only within files in the same assembly, as in this example: C# Copy.

What is difference between internal and private in C#?

protected internal: The type or member can be accessed by any code in the assembly in which it's declared, or from within a derived class in another assembly. private protected: The type or member can be accessed by types derived from the class that are declared within its containing assembly.

Why we use get set property in C#?

A get property accessor is used to return the property value, and a set property accessor is used to assign a new value. In C# 9 and later, an init property accessor is used to assign a new value only during object construction. These accessors can have different access levels.


1 Answers

If you have a property with an internal set accessor (and public get accessor) it means that code within the assembly can read (get) and write (set) the property, but other code can only read it.

You can derive the above information by reading about the internal access modifier, the public access modifier and properties.

Also, you can read about Restricting Accessor Accessibility.

like image 133
George Duckett Avatar answered Sep 19 '22 08:09

George Duckett