Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/csharp/fundamentals/types/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ C# provides a standard set of built-in types. These represent integers, floating

## Custom types

You use the [`struct`](../../language-reference/builtin-types/struct.md), [`class`](../../language-reference/keywords/class.md), [`interface`](../../language-reference/keywords/interface.md), [`enum`](../../language-reference/builtin-types/enum.md), and [`record`](../../language-reference/builtin-types/record.md) constructs to create your own custom types. The .NET class library itself is a collection of custom types that you can use in your own applications. By default, the most frequently used types in the class library are available in any C# program. Others become available only when you explicitly add a project reference to the assembly that defines them. After the compiler has a reference to the assembly, you can declare variables (and constants) of the types declared in that assembly in source code. For more information, see [.NET Class Library](../../../standard/class-library-overview.md).
You use the [`struct`](../../language-reference/builtin-types/struct.md), [`class`](../../language-reference/keywords/class.md), [`interface`](../../language-reference/keywords/interface.md), [`enum`](../../language-reference/builtin-types/enum.md), and [`record`](../../language-reference/builtin-types/record.md) constructs to create your own custom types. The .NET class library itself is a collection of custom types that you can use in your own applications. By default, the most frequently used types in the class library are available in any C# program. Others become available only when you explicitly add a project reference to the assembly that defines them. After the compiler has a reference to the assembly, you can declare variables (and constants) of the types declared in that assembly in source code.

One of the first decisions you make when defining a type is deciding which construct to use for your type. The following list helps make that initial decision. There's overlap in the choices. In most scenarios, more than one option is a reasonable choice.

Expand Down Expand Up @@ -82,14 +82,14 @@ The following illustration shows the relationship between value types and refere

Classes and structs are two of the basic constructs of the common type system in .NET. Each is essentially a data structure that encapsulates a set of data and behaviors that belong together as a logical unit. The data and behaviors are the *members* of the class, struct, or record. The members include its methods, properties, events, and so on, as listed later in this article.

A class, struct, or record declaration is like a blueprint that is used to create instances or objects at run time. If you define a class, struct, or record named `Person`, `Person` is the name of the type. If you declare and initialize a variable `p` of type `Person`, `p` is said to be an object or instance of `Person`. Multiple instances of the same `Person` type can be created, and each instance can have different values in its properties and fields.
A class, struct, or record declaration is like a blueprint that is used to create instances or objects at run time. If you define a class, struct, or record named `Person`, `Person` is the name of the type. If you declare and initialize a variable `p` of type `Person`, `p` is said to be an object or instance of `Person`. Multiple instances of the same `Person` type can be created, and each instance can have different values in its properties and fields.

A class is a reference type. When an object of the type is created, the variable to which the object is assigned holds only a reference to that memory. When the object reference is assigned to a new variable, the new variable refers to the original object. Changes made through one variable are reflected in the other variable because they both refer to the same data.

A struct is a value type. When a struct is created, the variable to which the struct is assigned holds the struct's actual data. When the struct is assigned to a new variable, it's copied. The new variable and the original variable therefore contain two separate copies of the same data. Changes made to one copy don't affect the other copy.

Record types can be either reference types (`record class`) or value types (`record struct`). Record types contain methods that support value-equality.

In general, classes are used to model more complex behavior. Classes typically store data that is intended to be modified after a class object is created. Structs are best suited for small data structures. Structs typically store data that isn't intended to be modified after the struct is created. Record types are data structures with extra compiler synthesized members. Records typically store data that isn't intended to be modified after the object is created.

### Value types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,53 @@ ms.assetid: 52ff0e32-3e5a-41de-9a3b-7b04ea52b83e
---
# DataTables

A <xref:System.Data.DataSet> is made up of a collection of tables, relationships, and constraints. In ADO.NET, <xref:System.Data.DataTable> objects are used to represent the tables in a **DataSet**. A **DataTable** represents one table of in-memory relational data; the data is local to the .NET-based application in which it resides, but can be populated from a data source such as Microsoft SQL Server using a **DataAdapter** For more information, see [Populating a DataSet from a DataAdapter](../populating-a-dataset-from-a-dataadapter.md).
The **DataTable** class is a member of the **System.Data** namespace within the .NET Framework class library. You can create and use a **DataTable** independently or as a member of a **DataSet**, and **DataTable** objects can also be used in conjunction with other .NET Framework objects, including the <xref:System.Data.DataView>. You access the collection of tables in a **DataSet** through the **Tables** property of the **DataSet** object.
The schema, or structure of a table is represented by columns and constraints. You define the schema of a **DataTable** using <xref:System.Data.DataColumn> objects as well as <xref:System.Data.ForeignKeyConstraint> and <xref:System.Data.UniqueConstraint> objects. The columns in a table can map to columns in a data source, contain calculated values from expressions, automatically increment their values, or contain primary key values.
In addition to a schema, a **DataTable** must also have rows to contain and order data. The <xref:System.Data.DataRow> class represents the actual data contained in a table. You use the **DataRow** and its properties and methods to retrieve, evaluate, and manipulate the data in a table. As you access and change the data within a row, the **DataRow** object maintains both its current and original state.
You can create parent-child relationships between tables using one or more related columns in the tables. You create a relationship between **DataTable** objects using a <xref:System.Data.DataRelation>. **DataRelation** objects can then be used to return the related child or parent rows of a particular row. For more information, see [Adding DataRelations](adding-datarelations.md).
## In This Section

[Creating a DataTable](creating-a-datatable.md)
Explains how to create a **DataTable** and add it to a **DataSet**.
[DataTable Schema Definition](datatable-schema-definition.md)
Provides information about creating and using **DataColumn** objects and constraints.
[Manipulating Data in a DataTable](manipulating-data-in-a-datatable.md)
Explains how to add, modify, and delete data in a table. Explains how to use **DataTable** events to examine changes to data in the table.
[Handling DataTable Events](handling-datatable-events.md)
Provides information about the events available for use with a **DataTable**, including events when column values are modified and rows are added or deleted.
## Related Sections

[ADO.NET](../index.md)
Describes the ADO.NET architecture and components, and how to use them to access existing data sources and manage application data.
[DataSets, DataTables, and DataViews](index.md)
Provides information about the ADO.NET **DataSet** including how to create relationships between tables.
<xref:System.Data.Constraint>
Provides reference information about the **Constraint** object.
<xref:System.Data.DataColumn>
Provides reference information about the **DataColumn** object.
<xref:System.Data.DataSet>
Provides reference information about the **DataSet** object.
<xref:System.Data.DataTable>
Provides reference information about the **DataTable** object.
[Class Library Overview](../../../../standard/class-library-overview.md)
Provides an overview of the .NET Framework class library, including the **System** namespace as well as its second-level namespace, **System.Data**.
A <xref:System.Data.DataSet> is made up of a collection of tables, relationships, and constraints. In ADO.NET, <xref:System.Data.DataTable> objects are used to represent the tables in a **DataSet**. A **DataTable** represents one table of in-memory relational data; the data is local to the .NET-based application in which it resides, but can be populated from a data source such as Microsoft SQL Server using a **DataAdapter** For more information, see [Populating a DataSet from a DataAdapter](../populating-a-dataset-from-a-dataadapter.md).

The **DataTable** class is a member of the **System.Data** namespace within the .NET Framework class library. You can create and use a **DataTable** independently or as a member of a **DataSet**, and **DataTable** objects can also be used in conjunction with other .NET Framework objects, including the <xref:System.Data.DataView>. You access the collection of tables in a **DataSet** through the **Tables** property of the **DataSet** object.

The schema, or structure of a table is represented by columns and constraints. You define the schema of a **DataTable** using <xref:System.Data.DataColumn> objects as well as <xref:System.Data.ForeignKeyConstraint> and <xref:System.Data.UniqueConstraint> objects. The columns in a table can map to columns in a data source, contain calculated values from expressions, automatically increment their values, or contain primary key values.

In addition to a schema, a **DataTable** must also have rows to contain and order data. The <xref:System.Data.DataRow> class represents the actual data contained in a table. You use the **DataRow** and its properties and methods to retrieve, evaluate, and manipulate the data in a table. As you access and change the data within a row, the **DataRow** object maintains both its current and original state.

You can create parent-child relationships between tables using one or more related columns in the tables. You create a relationship between **DataTable** objects using a <xref:System.Data.DataRelation>. **DataRelation** objects can then be used to return the related child or parent rows of a particular row. For more information, see [Adding DataRelations](adding-datarelations.md).

## In This Section

[Creating a DataTable](creating-a-datatable.md)
Explains how to create a **DataTable** and add it to a **DataSet**.

[DataTable Schema Definition](datatable-schema-definition.md)
Provides information about creating and using **DataColumn** objects and constraints.

[Manipulating Data in a DataTable](manipulating-data-in-a-datatable.md)
Explains how to add, modify, and delete data in a table. Explains how to use **DataTable** events to examine changes to data in the table.

[Handling DataTable Events](handling-datatable-events.md)
Provides information about the events available for use with a **DataTable**, including events when column values are modified and rows are added or deleted.

## Related Sections

[ADO.NET](../index.md)\
Describes the ADO.NET architecture and components, and how to use them to access existing data sources and manage application data.

[DataSets, DataTables, and DataViews](index.md)\
Provides information about the ADO.NET <xref:System.Data.DataSet> including how to create relationships between tables.

<xref:System.Data.Constraint>\
Provides reference information about the **Constraint** object.

<xref:System.Data.DataColumn>\
Provides reference information about the **DataColumn** object.

<xref:System.Data.DataSet>\
Provides reference information about the **DataSet** object.

<xref:System.Data.DataTable>\
Provides reference information about the **DataTable** object.

[Core .NET libraries overview](../../../../standard/class-library-overview.md)\
Provides an overview of the .NET class library.

## See also

- [ADO.NET Overview](../ado-net-overview.md)
Loading