This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Using Properties (C# Programming Guide)

  • 16 contributors

Properties combine aspects of both fields and methods. To the user of an object, a property appears to be a field; accessing the property requires the same syntax. To the implementer of a class, a property is one or two code blocks, representing a get accessor and/or a set accessor. The code block for the get accessor is executed when the property is read; the code block for the set accessor is executed when the property is assigned a value. A property without a set accessor is considered read-only. A property without a get accessor is considered write-only. A property that has both accessors is read-write. You can use an init accessor instead of a set accessor to make the property read-only.

Unlike fields, properties aren't classified as variables. Therefore, you can't pass a property as a ref or out parameter.

Properties have many uses: they can validate data before allowing a change; they can transparently expose data on a class where that data is retrieved from some other source, such as a database; they can take an action when data is changed, such as raising an event, or changing the value of other fields.

Properties are declared in the class block by specifying the access level of the field, followed by the type of the property, followed by the name of the property, and followed by a code block that declares a get -accessor and/or a set accessor. For example:

In this example, Month is declared as a property so that the set accessor can make sure that the Month value is set between 1 and 12. The Month property uses a private field to track the actual value. The real location of a property's data is often referred to as the property's "backing store." It's common for properties to use private fields as a backing store. The field is marked private in order to make sure that it can only be changed by calling the property. For more information about public and private access restrictions, see Access Modifiers .

Auto-implemented properties provide simplified syntax for simple property declarations. For more information, see Auto-Implemented Properties .

The get accessor

The body of the get accessor resembles that of a method. It must return a value of the property type. The execution of the get accessor is equivalent to reading the value of the field. For example, when you're returning the private variable from the get accessor and optimizations are enabled, the call to the get accessor method is inlined by the compiler so there's no method-call overhead. However, a virtual get accessor method can't be inlined because the compiler doesn't know at compile-time which method may actually be called at run time. The following example shows a get accessor that returns the value of a private field _name :

When you reference the property, except as the target of an assignment, the get accessor is invoked to read the value of the property. For example:

The get accessor must end in a return or throw statement, and control can't flow off the accessor body.

It's a bad programming style to change the state of the object by using the get accessor.

The get accessor can be used to return the field value or to compute it and return it. For example:

In the previous code segment, if you don't assign a value to the Name property, it will return the value NA .

The set accessor

The set accessor resembles a method whose return type is void . It uses an implicit parameter called value , whose type is the type of the property. In the following example, a set accessor is added to the Name property:

When you assign a value to the property, the set accessor is invoked by using an argument that provides the new value. For example:

It's an error to use the implicit parameter name, value , for a local variable declaration in a set accessor.

The init accessor

The code to create an init accessor is the same as the code to create a set accessor except that you use the init keyword instead of set . The difference is that the init accessor can only be used in the constructor or by using an object-initializer .

Properties can be marked as public , private , protected , internal , protected internal , or private protected . These access modifiers define how users of the class can access the property. The get and set accessors for the same property may have different access modifiers. For example, the get may be public to allow read-only access from outside the type, and the set may be private or protected . For more information, see Access Modifiers .

A property may be declared as a static property by using the static keyword. Static properties are available to callers at any time, even if no instance of the class exists. For more information, see Static Classes and Static Class Members .

A property may be marked as a virtual property by using the virtual keyword. Virtual properties enable derived classes to override the property behavior by using the override keyword. For more information about these options, see Inheritance .

A property overriding a virtual property can also be sealed , specifying that for derived classes it's no longer virtual. Lastly, a property can be declared abstract . Abstract properties don't define an implementation in the class, and derived classes must write their own implementation. For more information about these options, see Abstract and Sealed Classes and Class Members .

It is an error to use a virtual , abstract , or override modifier on an accessor of a static property.

This example demonstrates instance, static, and read-only properties. It accepts the name of the employee from the keyboard, increments NumberOfEmployees by 1, and displays the Employee name and number.

Hidden property example

This example demonstrates how to access a property in a base class that is hidden by another property that has the same name in a derived class:

The following are important points in the previous example:

  • The property Name in the derived class hides the property Name in the base class. In such a case, the new modifier is used in the declaration of the property in the derived class: public new string Name
  • The cast (Employee) is used to access the hidden property in the base class: ((Employee)m1).Name = "Mary";

For more information about hiding members, see the new Modifier .

Override property example

In this example, two classes, Cube and Square , implement an abstract class, Shape , and override its abstract Area property. Note the use of the override modifier on the properties. The program accepts the side as an input and calculates the areas for the square and cube. It also accepts the area as an input and calculates the corresponding side for the square and cube.

  • Interface Properties
  • Auto-Implemented Properties

Submit and view feedback for

Additional resources

C# Tutorial

C# examples, c# properties (get and set), properties and encapsulation.

Before we start to explain properties, you should have a basic understanding of " Encapsulation ".

  • declare fields/variables as private
  • provide public get and set methods, through properties , to access and update the value of a private field

You learned from the previous chapter that private variables can only be accessed within the same class (an outside class has no access to it). However, sometimes we need to access them - and it can be done with properties.

A property is like a combination of a variable and a method, and it has two methods: a get and a set method:

Example explained

The Name property is associated with the name field. It is a good practice to use the same name for both the property and the private field, but with an uppercase first letter.

The get method returns the value of the variable name .

The set method assigns a value to the name variable. The value keyword represents the value we assign to the property.

If you don't fully understand it, take a look at the example below.

Now we can use the Name property to access and update the private field of the Person class:

The output will be:

Try it Yourself »


Automatic Properties (Short Hand)

C# also provides a way to use short-hand / automatic properties, where you do not have to define the field for the property, and you only have to write get; and set; inside the property.

The following example will produce the same result as the example above. The only difference is that there is less code:

Using automatic properties:

Why Encapsulation?

  • Better control of class members (reduce the possibility of yourself (or others) to mess up the code)
  • Fields can be made read-only (if you only use the get method), or write-only (if you only use the set method)
  • Flexible: the programmer can change one part of the code without affecting other parts
  • Increased security of data

Get Certified



Report Error

If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

[email protected]

Top Tutorials

Top references, top examples, get certified.

  • PyQt5 ebook
  • Tkinter ebook
  • SQLite Python
  • wxPython ebook
  • Windows API ebook
  • Java Swing ebook
  • Java games ebook
  • MySQL Java ebook

C# Property

last modified January 31, 2024

In this article we show how to work with properties in C#.

A property is a member that provides a flexible mechanism to read, write, or compute the value of a private field.

Properties use accessors through which the values of the private fields can be read, written or manipulated. Property reads and writes are translated to get and set method calls. Properties shield the data from the outside world while having a convenient field access.

A get property accessor is used to return the property value, and a set property accessor is used to assign a new value. The init property accessor is used to assign a new value only during object construction. The value keyword is used to define the value that is assigned by the set or init accessor.

Properties can be read-write (they have both a get and a set accessor), read-only (they have only a get accessor), or write-only (they have only a set accessor).

C# Property with backing field

The following example uses a property with a backing field.

We have the Name property with the _name backing field.

We create an instance of the User class. We access the member field using the field notation.

We have a property that is called Name . It looks like a regular method declaration. The difference is that it has specific accessors called get and set .

The get property accessor is used to return the property value and the set accessor is used to assign a new value. The value keyword is used to define the value being assigned by the set accessor.

C# read-only property

To create a read-only property, we omit the set accessor and provide only the get accessor in the implementation.

In the example, we have read-only properties. Once initialized in the constructor, they cannot be modified.

We make the property read-only by providing a get accessor only.

C# auto-implemented properties

C# has auto-implemented or automatic properties. With automatic properties, the compiler transparently provides the backing fields for us.

This code is much shorter. We have a User class in which we have two properties: Name and Occupation .

We normally use the properties as usual.

Here we have two automatic properties. There is no implementation of the accessors and there are no member fields. The compiler will do the rest for us.

C# init-only property

The init keyword is used to create init-only properties; these properties can be initialized only during object construction.

We define two init-only properties; they are initialized at the object construction. Later, they become immutable.

We use the primary constructor. It gives us two parameters: name and occupation . They are later used to initialize properties.

The init-only properties are created with the init keyword.

C# required properties

The required keyword is used to force the clien to implement the property.

We must use object initializers to create an object with a required property.

C# expression body definitions

Properties can be simplified with expression body definitions. Expression body definitions consist of the => symbol followed by the expression to assign to or retrieve from the property.

In the example, we use the expression body definitions to define properties for the User class.

Other notes

We can mark properties with access modifiers like public , private or protected . Properties can be also static , abstract , virtual and sealed . Their usage is identical to regular methods.

In the preceding example, we define a virtual property and override it in the Derived class.

The Name property is marked with the virtual keyword.

We are hiding a member in the Derived class. To suppress the compiler warning, we use the new keyword.

And here we override the Name property of the Base class.

Properties - programming guide

In this article we have covered C# properties.

My name is Jan Bodnar and I am a passionate programmer with many years of programming experience. I have been writing programming articles since 2007. So far, I have written over 1400 articles and 8 e-books. I have over eight years of experience in teaching programming.

List all C# tutorials .

Home » C# Tutorial » C# Property

C# Property

Summary : in this tutorial, you’ll about the C# property and how to use the properties effectively.

Introduction to the C# property

By definition, a property is a member of a class that provides a flexible way to read, write, or compute the value of a private field.

For example, the following defines the class Person with three private fields firstName , lastName , and age :

To assign values to and read values from these private fields, you use properties. The following shows how to add three properties to the Person class:

In this example, we declare a property like a field with a get and set blocks. The get and set are called the property accessors.

When you read from a property, the get accessor executes. And when you assign a value to a property, the set accessor executes. For example:

In this example:

  • First, create an instance of the Person class.
  • Second, assign the values to the FirstName and LastName properties.
  • Third, read values from the FirstName and LastName properties.

Using C# property for data validation

Since a property provides a central place to assign a value to a private field, you can validate the data and throw an exception if the data is not valid.

Suppose you want to implement the following validation rules:

  • The first name and last name are not null or empty
  • The age is between 1 and 150

To do that, you can add the validation logic to the set accessors of the properties as shown in the following example:

The following program causes an exception because the age is out of the valid range (1-150)

C# computed property

To create a computed property, you can implement the get accessor. For example, you can create a FullName property that returns the concatenation of the first name and last name:

And you can read from the FullName property:

If you attempt to assign a value to the FullName property, you’ll get a compilation error. For example:

C# auto-implemented properties

If you have a property that requires no additional logic in the set or get accessors, you can use an auto-implemented property.

The following example defines the Skill class that has two private fields name and rating , and the corresponding properties:

Since the accessors of the properties have no additional logic besides reading from and writing to private fields, you can use auto-implemented properties like this:

When the C# compiler encounters an auto-implemented property, it creates a private, anonymous field that can be accessed through the set and get accessors.

As you can see, the auto-implemented properties make the code more concise in this case.

In C# 9 or later, you can init an auto-implemented property like this:

In this example, we initialize the Rating property so that its value is one when you create a new instance of the Skill class.

  • A property is a member of a class that provides a flexible way to read, write, or compute the value of a private field.
  • A property contains get and/or set accessors.
  • The get accessor executes when you read the value from the property while the set accessor executes when you assign a value to the property.
  • Use auto-implemented property if the get and set accessors have no additional logic to make the code more concise.

C# Corner

  • An Interview Question


C# Property

assign property c#

  • Sandeep Singh Shekhawat
  • Feb 01, 2019
  • Other Artcile

C# property is a member of a class that allows the class to expose some functionality without exposing the implementation details. This article explains what a property is in C#, why we need properties, and how to implement properties in C# and .NET.

I am assuming that you already know how to declare a variable and assign a value in a class. If you need more details, check out this free ebook - Beginning C# Object Oriented Programming.

  • What property is
  • How can we implement a property
  • How do we use a property


Declare and read/write example of property.

  • namespace  PropertyExample  
  • {  
  •      public   class  Person  
  •     {  
  •          private   string  mName =  string .Empty;  
  •          private   int  mAge = 0;  
  •          public   string  Name  
  •         {  
  •              get   
  •             {  
  •                  return  mName;  
  •             }  
  •              set   
  •                 mName = value;  
  •         }  
  •          public   int  Age  
  •                  return  mAge;  
  •                 mAge = value;  
  •     }  
  • }  


  • objPerson.Name =  "Sandeep Singh" ;  
  • Console.WriteLine( "Your Name is :{0}" , objPerson.Name);  

Create Readonly Property

  • public   class  Person  
  •      public   string  Gender  
  •          get  {  return   "Male" ;}  


Create WriteOnly Property

  •      private   string  mFirstName =  string .Empty;  
  •      public   string  FirstName  
  •          set {mFirstName = value;}  


Assign Values to Properties on Object Creation

  • Person objPerson =  new  Person()  
  •     Name =  "Sandeep Singh" ,  
  •     Age = 24  
  • };  

Validate Property Value

  • using  System;  
  •      public   class  Voter  
  •     {      
  •          private   int  mAge = 0;          
  •             get   
  •             set   
  •                  if  (value >= 18)  
  •                 {  
  •                     mAge = value;  
  •                 }  
  •                 else   
  •                     Console.WriteLine( "You are not eligible for voting" );         
  •      class  Program  
  •          static   void  Main( string [] args)  
  •             Voter objVoter =  new  Voter();  
  •             Console.WriteLine( "Please enter your age" );  
  •             objVoter.Age = Convert.ToInt32(Console.ReadLine());  
  •             Console.WriteLine( "Your age is :{0} years" , objVoter.Age);  
  •             Console.ReadKey();  


Use of Property as a method

  •      public   class  Student  
  •          private   int  mMarks = 0;          
  •          public   int  Marks  
  •                  if (mMarks >= 80)  
  •                     mMarks+=5;  
  •                  else   if (mMarks <= 79 && mMarks>=70 )  
  •                     mMarks+=2;                          
  •                 }                     
  •                  return  mMarks;  
  •                 mMarks = value;  
  •             Student objStudent =  new  Student();  
  •             Console.WriteLine( "Please enter your marks" );  
  •             objStudent.Marks = Convert.ToInt32(Console.ReadLine());  
  •             Console.WriteLine( "Your marks are :{0} marks" , objStudent.Marks);  


Auto mapped property

We can also create auto mapped property. When we create auto mapped property then we don't need define to local private field in get and set accessors. For example we have an employee class which has two properties,  one in EmployeeId and another is Name. To define these properties we don't need to create a private field for these two properties and directly declare it.

  •      public   class  Employee  
  •          public   int  EmployeeId {  get ;  set ; }  
  •          public   string  Name {  get ;  set ; }  
  •             Employee objEmployee =  new  Employee()  
  •                                     {  
  •                                         EmployeeId = 1001,  
  •                                         Name =  "Sandeep"   
  •                                     };  
  •             Console.WriteLine( "Employee Id is :{0} and Employee Name is :{1}" , objEmployee.EmployeeId, objEmployee.Name);  
  • C# property
  • Property Value
  • Write property
  • WriteOnly property

C# Corner Ebook

The SOLID Principles

  • United States
  • United Kingdom

Joydip Kanjilal

By Joydip Kanjilal , Contributor, InfoWorld |

When to use classes, structs, or records in C#

Learn how to choose between classes, structs, and record types in c# for power, flexibility, efficiency, and performance..

shutterstock 435558448 old clocks on brick wall time, time change, timeless

Classes, structs, and records are fundamental concepts in C# programming . Each is a different kind of type, with different features, capabilities, and limitations. To make matters more confusing, they have features and characteristics in common.

Classes are reference types that provide support for useful object-oriented concepts such as encapsulation, inheritance, and polymorphism. Structs are value types that offer better performance but have limitations in terms of size and mutability. Records, which were introduced in C# 9, combine the best of both classes and structs, with support for immutability by default.

When should you use structs or records instead of classes in your application? In this article we will examine the differences between classes, structs, and record types and how we should work with these different types in C#.

Create a console application project in Visual Studio

First off, let’s create a .NET Core console application project in Visual Studio. Assuming Visual Studio 2022 is installed in your system, follow the steps outlined below to create a new .NET Core console application project.

  • Launch the Visual Studio IDE.
  • Click on “Create new project.”
  • In the “Create new project” window, select “Console App (.NET Core)” from the list of templates displayed.
  • Click Next.
  • In the “Configure your new project” window, specify the name and location for the new project.
  • In the “Additional information” window shown next, choose “.NET 8.0 (Long Term Support)” as the framework version. Leave the “Do not use top-level statements” and “Enable native AOT publish" check boxes unchecked. We won’t be using those features here.
  • Click Create.

We’ll use this .NET 8 console application project to work with examples of classes, structs, and records in the subsequent sections of this article.

Using classes in C#

A class in C# is a reference type. In other words, a variable of a class type holds a reference to an object. Note that you can have multiple references that point to the same object (so modifying the object through one reference will change its value for others). The members of a class (i.e., its fields, properties, methods, events, etc.) define the behavior and state of the instances of the class.

Classes in C# support abstraction, encapsulation, inheritance, and polymorphism. These are the four basic principles of object-oriented programming.

The following code snippet shows the syntax for defining a class in C#.

The following code snippet illustrates a typical C# class.

The code snippet below shows how you can instantiate the Author class and set values to each of its properties.

Using structs in C#

A struct in C# is a value type. A variable of a struct type holds an instance of the type (not a reference). You can use structs in C# to build small composite data types while avoiding the garbage collection overhead. Structs can also be made immutable, using the readonly modifier.

Note that instances of structs are passed by value when you use them as a method parameter. Likewise, when you assign one struct variable to another struct variable, its value is copied.

While you can use fields, properties, and methods in a struct, you cannot implement object-oriented concepts such as abstraction, encapsulation, inheritance, and polymorphism using a struct.

The following code snippet shows the syntax for defining a struct in C#.

The following code snippet illustrates a typical struct.

You can now use the following piece of code to create an instance of this struct and initialize its data members.

Using records in C#

Record types were introduced in C# 9 for representing immutable values. Records are reference types like classes, but they have value-based equality semantics by default, like structs. You can use record types in C# to build immutable types and thread-safe objects.

Records provide handy built-in features such as a with expression to create a new record with modified data, and a init accessor to set values to its properties only at the time of initialization. Record types can have properties, fields, methods, events, and constructors, and they provide limited support for inheritance. However, they do not support abstraction, encapsulation, and polymorphism.

You can take advantage of record types to represent data transfer objects (DTOs), as well as other data structures that require immutability and equality semantics.

Consider the following code that shows a C# class named Rectangle.

You can represent the same data using a record type in a much simpler way:

You can now create an instance of the Rectangle record type using the following code.

Using inheritance in record types in C#

A record type in C# can inherit from another record type, but it cannot inherit from a class. The following code snippet shows how one record type can extend another record type in C#.

You can now create an instance of the record type using the following code.

Classes vs. structs vs. records in C#

Use classes to represent complex logic and behavior in your application. Classes were designed to model complex data structures that require object-oriented concepts such as abstraction, encapsulation, composition, inheritance, and polymorphism. However, classes have certain performance drawbacks that you should keep in mind when designing your applications.

Value types (structs) are much more cost-effective in terms of memory allocation and deallocation than reference types (classes and records). When you want to create a composite data type with only a few data members, a struct is a good choice. Structs are ideal for small data structures (less than 16 bytes in size) that require value semantics. Using a struct in such cases will help you avoid garbage collection costs and related overheads.

Record types fill a gap between reference types and value types, and help you to write code that is clean, lean, and readable. Choose a record type over a class or a struct when data is your primary concern. Use record types to create data transfer objects, API response objects, configuration objects, immutable models, and value objects in domain-driven design.

Record types provide excellent support for pattern matching, making them a good choice for working with complex data structures. Record types are designed to be immutable data types by default—a feature that facilitates functional programming, where you cannot modify an instance once it has been created.

When deciding whether to use classes, structs, or records in C#, consider their intended usage, features, equality comparison, immutability, and performance characteristics. In a nutshell, classes are suitable when you need objects with behavior and complex logic, structs are suitable for lightweight values and minimal behavior, and records are ideal for immutable data structures with straightforward equality rules.

Next read this:

  • Why companies are leaving the cloud
  • 5 easy ways to run an LLM locally
  • Coding with AI: Tips and best practices from developers
  • Meet Zig: The modern alternative to C
  • What is generative AI? Artificial intelligence that creates
  • The best open source software of 2023
  • Microsoft .NET
  • Development Libraries and Frameworks
  • Software Development

Joydip Kanjilal is a Microsoft MVP in ASP.NET, as well as a speaker and author of several books and articles. He has more than 20 years of experience in IT including more than 16 years in Microsoft .NET and related technologies.

Copyright © 2024 IDG Communications, Inc.

assign property c#

assign property c#

Create a form in Word that users can complete or print

In Word, you can create a form that others can fill out and save or print.  To do this, you will start with baseline content in a document, potentially via a form template.  Then you can add content controls for elements such as check boxes, text boxes, date pickers, and drop-down lists. Optionally, these content controls can be linked to database information.  Following are the recommended action steps in sequence.  

Show the Developer tab

In Word, be sure you have the Developer tab displayed in the ribbon.  (See how here:  Show the developer tab .)

Open a template or a blank document on which to base the form

You can start with a template or just start from scratch with a blank document.

Start with a form template

Go to File > New .

In the  Search for online templates  field, type  Forms or the kind of form you want. Then press Enter .

In the displayed results, right-click any item, then select  Create. 

Start with a blank document 

Select Blank document .

Add content to the form

Go to the  Developer  tab Controls section where you can choose controls to add to your document or form. Hover over any icon therein to see what control type it represents. The various control types are described below. You can set properties on a control once it has been inserted.

To delete a content control, right-click it, then select Remove content control  in the pop-up menu. 

Note:  You can print a form that was created via content controls. However, the boxes around the content controls will not print.

Insert a text control

The rich text content control enables users to format text (e.g., bold, italic) and type multiple paragraphs. To limit these capabilities, use the plain text content control . 

Click or tap where you want to insert the control.

Rich text control button

To learn about setting specific properties on these controls, see Set or change properties for content controls .

Insert a picture control

A picture control is most often used for templates, but you can also add a picture control to a form.

Picture control button

Insert a building block control

Use a building block control  when you want users to choose a specific block of text. These are helpful when you need to add different boilerplate text depending on the document's specific purpose. You can create rich text content controls for each version of the boilerplate text, and then use a building block control as the container for the rich text content controls.

building block gallery control

Select Developer and content controls for the building block.

Developer tab showing content controls

Insert a combo box or a drop-down list

In a combo box, users can select from a list of choices that you provide or they can type in their own information. In a drop-down list, users can only select from the list of choices.

combo box button

Select the content control, and then select Properties .

To create a list of choices, select Add under Drop-Down List Properties .

Type a choice in Display Name , such as Yes , No , or Maybe .

Repeat this step until all of the choices are in the drop-down list.

Fill in any other properties that you want.

Note:  If you select the Contents cannot be edited check box, users won’t be able to click a choice.

Insert a date picker

Click or tap where you want to insert the date picker control.

Date picker button

Insert a check box

Click or tap where you want to insert the check box control.

Check box button

Use the legacy form controls

Legacy form controls are for compatibility with older versions of Word and consist of legacy form and Active X controls.

Click or tap where you want to insert a legacy control.

Legacy control button

Select the Legacy Form control or Active X Control that you want to include.

Set or change properties for content controls

Each content control has properties that you can set or change. For example, the Date Picker control offers options for the format you want to use to display the date.

Select the content control that you want to change.

Go to Developer > Properties .

Controls Properties  button

Change the properties that you want.

Add protection to a form

If you want to limit how much others can edit or format a form, use the Restrict Editing command:

Open the form that you want to lock or protect.

Select Developer > Restrict Editing .

Restrict editing button

After selecting restrictions, select Yes, Start Enforcing Protection .

Restrict editing panel

Advanced Tip:

If you want to protect only parts of the document, separate the document into sections and only protect the sections you want.

To do this, choose Select Sections in the Restrict Editing panel. For more info on sections, see Insert a section break .

Sections selector on Resrict sections panel

If the developer tab isn't displayed in the ribbon, see Show the Developer tab .

Open a template or use a blank document

To create a form in Word that others can fill out, start with a template or document and add content controls. Content controls include things like check boxes, text boxes, and drop-down lists. If you’re familiar with databases, these content controls can even be linked to data.

Go to File > New from Template .

New from template option

In Search, type form .

Double-click the template you want to use.

Select File > Save As , and pick a location to save the form.

In Save As , type a file name and then select Save .

Start with a blank document

Go to File > New Document .

New document option

Go to File > Save As .

Go to Developer , and then choose the controls that you want to add to the document or form. To remove a content control, select the control and press Delete. You can set Options on controls once inserted. From Options, you can add entry and exit macros to run when users interact with the controls, as well as list items for combo boxes, .

Adding content controls to your form

In the document, click or tap where you want to add a content control.

On Developer , select Text Box , Check Box , or Combo Box .

Developer tab with content controls

To set specific properties for the control, select Options , and set .

Repeat steps 1 through 3 for each control that you want to add.

Set options

Options let you set common settings, as well as control specific settings. Select a control and then select Options to set up or make changes.

Set common properties.

Select Macro to Run on lets you choose a recorded or custom macro to run on Entry or Exit from the field.

Bookmark Set a unique name or bookmark for each control.

Calculate on exit This forces Word to run or refresh any calculations, such as total price when the user exits the field.

Add Help Text Give hints or instructions for each field.

OK Saves settings and exits the panel.

Cancel Forgets changes and exits the panel.

Set specific properties for a Text box

Type Select form Regular text, Number, Date, Current Date, Current Time, or Calculation.

Default text sets optional instructional text that's displayed in the text box before the user types in the field. Set Text box enabled to allow the user to enter text into the field.

Maximum length sets the length of text that a user can enter. The default is Unlimited .

Text format can set whether text automatically formats to Uppercase , Lowercase , First capital, or Title case .

Text box enabled Lets the user enter text into a field. If there is default text, user text replaces it.

Set specific properties for a Check box .

Default Value Choose between Not checked or checked as default.

Checkbox size Set a size Exactly or Auto to change size as needed.

Check box enabled Lets the user check or clear the text box.

Set specific properties for a Combo box

Drop-down item Type in strings for the list box items. Press + or Enter to add an item to the list.

Items in drop-down list Shows your current list. Select an item and use the up or down arrows to change the order, Press - to remove a selected item.

Drop-down enabled Lets the user open the combo box and make selections.

Protect the form

Go to Developer > Protect Form .

Protect form button on the Developer tab

Note:  To unprotect the form and continue editing, select Protect Form again.

Save and close the form.

Test the form (optional)

If you want, you can test the form before you distribute it.

Protect the form.

Reopen the form, fill it out as the user would, and then save a copy.

Creating fillable forms isn’t available in Word for the web.

You can create the form with the desktop version of Word with the instructions in Create a fillable form .

When you save the document and reopen it in Word for the web, you’ll see the changes you made.


Need more help?

Want more options.

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

assign property c#

Microsoft 365 subscription benefits

assign property c#

Microsoft 365 training

assign property c#

Microsoft security

assign property c#

Accessibility center

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

assign property c#

Ask the Microsoft Community

assign property c#

Microsoft Tech Community

assign property c#

Windows Insiders

Microsoft 365 Insiders

Was this information helpful?

Thank you for your feedback.

assign property c#

  • Residential

Apartments and flats for sale in Moscow, Russia

1 room studio apartment in Moscow, Russia

Properties features in Moscow, Russia

Site logo

Homes for Sale


  • Skyscrapers
  • Apartments for Sale
  • Apartments for Rent
  • Houses for Sale
  • Houses for Rent
  • Luxury Real Estate
  • Mansions in Russia
  • Palaces in Russia

Watch Video

  • Residence permit in Russia


With us, your property deal in Russia will be secure!

Real Estate in Moscow

We are an international real estate company situated in Moscow City , and our mission is to help expats find and purchase real estate for sale in Russia. You can use our database to search for all kinds of real estate listings, including rental apartments with excellent views located at the very heart of the capital, penthouses in Moscow’s celebrated residential complexes, suburban mansions and gated community  residences .

We provide a very wide choice of residential properties in those parts of the capital which are known for the greatest prestige; most notably, in the Patriarch’s Ponds area and the Arbat, Ostozhenka and Zamoskvorechye Districts. And if you are interested in palaces , mansions and cottages , we will find for you a selection of property for sale in the most high-status and historically prestigious communities and settlements of Moscow Oblast , particularly those concentrated around the Rublyovo-Uspenskoye and Novorizhskoye shosse. Just send us a request with your requirements!

Full Range of Services for Expats

You can come to us with whatever you need - we will even find a school for your children!

assign property c#

We offer advice on areas that are safe to live in and recommend the best banks for making international transactions. Our lawyers conduct thorough assessments of all relevant property documentation to safeguard you against seller fraud.

assign property c#

We provide visa assistance. We will help you with your migration registration and with obtaining a residence permit in Russia. We are always ready to resolve any problems you might have with obtaining a citizenship.

assign property c#

We provide help with resolving any issues related to the maintenance of your home. We will assist you in hiring domestic help and a nanny for your child. We will find a private British, American or French school for your children.

Properties for Sale in Russia

The listing shows examples of real estate prices

  • Contact for price

Luxury Moscow house

Luxury house 8290 sqft in Vnukovskoye settlement

  • Houses for Rent, Houses for Sale, Luxury Real Estate, Mansions In Russia

Moscow City apartment 50th floor

Moscow City apartment on the 50th floor

  • Apartments for Rent, Apartments for Sale, Luxury Real Estate, Moscow City apartments

Castle in Russia 9900000

Deauville Castle 10 km from Moscow

  • 13400 Sq Ft
  • Houses for Rent, Houses for Sale, Luxury Real Estate, Palaces In Russia

Elite mansion in Russia 780

Mansion 785 sqm in the most expensive place in the Moscow Oblast

  • $8,400/Monthly

assign property c#

3-room apartment 187 sqm on the 33rd floor

  • Apartments for Rent, Moscow City apartments
  • $5,100/Monthly

assign property c#

2-room apartment 102 sqm on the 45th floor

assign property c#

2-room apartment 60 sqm in Dokuchaev lane

assign property c#

5-room apartment 203 sqm on Minskaya street

  • $1,700/Monthly

assign property c#

3-room apartment 110 sqm in the north of Moscow

assign property c#

3-room apartment with Hyatt service

assign property c#

5-room apartment on Leninsky prospect

assign property c#

3-storey country house 960 sqm on Rublevka

  • 10333 Sq Ft
  • Houses for Rent, Houses for Sale
  • $6,700/Monthly

assign property c#

3-storey house 360 sqm with 4 bedrooms

  • $15,000/Monthly

assign property c#

Country house 1234 sqm on Rublevskoe highway

  • 13282 Sq Ft
  • Houses for Rent, Luxury Real Estate

assign property c#

Apartment 193 sqm on the 52nd floor of Moscow City

  • Moscow City apartments

Apartment with 1 bedroom with a total area of 90 m² in the OKO Towers on the 63rd floor

Apartment on the 63rd floor in the OKO tower

  • Apartments for Rent, Apartments for Sale, Moscow City apartments

3-storey house 4090 sqft in the village of Deauville in the Odintsovo district

House 380 sqm 12 km from Moscow

Novodmitrovskaya street 2k5

Penthouse 140 sqm on the 46th floor

Office in Moscow on the 84th floor

Office 107 sqm on the 84th floor of a skyscraper in Moscow

  • Commercial Property

Apartment near Petrovsky park 203

4 room apartment 203 sqm in the house with a swimming pool

  • Apartments for Sale, Luxury Real Estate
  • $18,000,000

Ilyinskoye field in the Moscow region 2

Modern house 2000 sqm on Rublevsky highway

  • 21530 Sq Ft
  • Houses for Sale, Luxury Real Estate, Mansions In Russia, Palaces In Russia

3-room apartment with brand new renovation in Art Deco style

Apartment 193 sqm on the 52nd floor in Moscow City

  • Apartments for Sale, Moscow City apartments

Restaurant in Moscow on Tverskaya

767 sqm premises for a restaurant in the city center

Cottage village Residence Club 900

House 900 sqm 12 km from Moscow

  • Houses for Sale, Luxury Real Estate, Mansions In Russia

Penthouse 284 Zvenigorodskoe highway 11

Apartment 76 sqm on the 34th floor in NEVA TOWER

House in the village of Gorki-2 716

House 750 sqm in the village of Gorki 2

  • Houses for Sale, Mansions In Russia
  • $85,000,000

Mercedes-Benz business center on Leningradsky Prospekt in Moscow

Business center with a Mercedes showroom

  • 177410 Sq Ft

Apartment 530 Knightsbridge Private Park

Townhouse 530 sqm in the very center of Moscow

  • Apartments for Sale, Houses for Sale, Luxury Real Estate

Mansion on the Minskoe highway 5 km from the Moscow Ring Road in the village of Moskvoretsky Forest Park

English-style mansion 8 km from Moscow

  • 26900 Sq Ft

assign property c#

Compare listings

Reset Password

Please enter your username or email address. You will receive a link to create a new password via email.

Send a Request


  1. Using Visual Studio shortcuts to create C# properties

    assign property c#

  2. c#

    assign property c#

  3. reference

    assign property c#

  4. c#

    assign property c#

  5. c#

    assign property c#

  6. c#

    assign property c#


  1. Assign Property

  2. Difference Between Field & Property In C# .Net


  4. SetValue in c#

  5. Auto Implemented Property In C#

  6. Read Only Property In C#


  1. Using Properties

    Properties are declared in the class block by specifying the access level of the field, followed by the type of the property, followed by the name of the property, and followed by a code block that declares a get -accessor and/or a set accessor. For example: C#

  2. What is the best way to give a C# auto-property an initial value?

    23 Answers Sorted by: 2945 In C# 5 and earlier, to give auto implemented properties an initial value, you have to do it in a constructor. Since C# 6.0, you can specify initial value in-line. The syntax is: public int X { get; set; } = x; // C# 6 or higher

  3. C# Properties (Get and Set)

    The set method assigns a value to the name variable. The value keyword represents the value we assign to the property. If you don't fully understand it, take a look at the example below. Now we can use the Name property to access and update the private field of the Person class: Example

  4. C# Property Examples

    We see automatically implemented property syntax in C#. A hidden field is generated—then the get and set statements are expanded to use that hidden field. Detail The *= operator is used to multiply the property by itself. Because properties are meant to look like fields, this is allowed. ... Here we assign the Quantity property of Medication ...

  5. C# Property

    A get property accessor is used to return the property value, and a set property accessor is used to assign a new value. The init property accessor is used to assign a new value only during object construction. The value keyword is used to define the value that is assigned by the set or init accessor.

  6. C# property

    First, create an instance of the Person class. Second, assign the values to the FirstName and LastName properties. Third, read values from the FirstName and LastName properties. Using C# property for data validation

  7. C# Property

    C# properties use get and set methods, also known as accessors to access and assign values to private fields. Now the question is what are accessors? The get and set portions or blocks of a property are called accessors.

  8. When to use classes, structs, or records in C#

    The members of a class (i.e., its fields, properties, methods, events, etc.) define the behavior and state of the instances of the class. Classes in C# support abstraction, encapsulation ...

  9. c#

    12 Answers Sorted by: 595 You can use Convert.ChangeType () - It allows you to use runtime information on any IConvertible type to change representation formats. Not all conversions are possible, though, and you may need to write special case logic if you want to support conversions from types that are not IConvertible.

  10. Create a form in Word that users can complete or print

    Show the Developer tab. If the developer tab isn't displayed in the ribbon, see Show the Developer tab.. Open a template or use a blank document. To create a form in Word that others can fill out, start with a template or document and add content controls.

  11. Apartments for Sale in Moscow, Russia

    Moscow, Russia. 1. 1. 30 m². 5/13. Studio apartment for sale, with an area of 30.4 square meters on the 5th floor of a business…. €94,040. Leave a request. 3 room apartment.

  12. Homes for Sale

    Search for real estate and find real estate listings. Homes for Sale | Century 21®. Get details of properties and view photos. Connect to real estate Agents on Century 21®

  13. C# Automatically assign property based on other property values

    public class SomeType { public string A { get; set; } public string C { get; set; } private string _b; public string B { get { return _b; } set { // Set B to some new value _b = value; // Assign C C = string.Format ("B has been set to {0}", value); } } } Share Improve this answer Follow answered Aug 29, 2010 at 8:38 Darin Dimitrov

  14. Moscow Rentals

    Most of the real estate properties for sale can be offered to you without an agency fee. You are welcome to buy a residential property with the help of our real estate agents. Our specialists will offer you all apartments for sale, all luxury penthouses for sale, houses for sale and commercial real estate for sale available in Moscow shortly ...

  15. C# get and set property by variable name

    4 Answers Sorted by: 34 Yes, your looking for the PropertyInfo.SetValue method e.g. var propInfo = info.GetType ().GetProperty (propertyName); if (propInfo != null) { propInfo.SetValue (info, value, null); } Share Improve this answer Follow answered Aug 6, 2012 at 7:51 James 81.2k 18 167 239 Add a comment 10

  16. Real Estate in Moscow Russia & Properties for Sale

    Mansion 785 sqm in the most expensive place in the Moscow Oblast. 55.686574, 37.089623. 6. 8450 Sq Ft. Houses for Rent, Houses for Sale, Luxury Real Estate, Mansions In Russia. Details. Featured. For Rent. $8,400/Monthly.

  17. c#

    Command MyCommand { get; } = new Command (); //works. here's what I changed it to. Command MyCommand => new Command (); //doesn't work properly. The difference here is when I use { get; } = I create and reference the SAME command in that property. When I use => I actually create a new command and return it every time the property is called.