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
2 changes: 1 addition & 1 deletion docs/core/rid-catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RID is short for *Runtime IDentifier*. RID values are used to identify target pl
They're used by .NET packages to represent platform-specific assets in NuGet packages. The following values are examples of RIDs: `linux-x64`, `ubuntu.14.04-x64`, `win7-x64`, or `osx.10.12-x64`.
For the packages with native dependencies, the RID designates on which platforms the package can be restored.

RIDs can be set in the `<RuntimeIdentifier>` element of your project file. They're also used via the `--runtime` option with the following [.NET Core CLI commands](./tools/index.md):
A single RID can be set in the `<RuntimeIdentifier>` element of your project file. Multiple RIDs can be defined as a semicolon-delimited list in the project file's `<RuntimeIdentifiers>` element. They're also used via the `--runtime` option with the following [.NET Core CLI commands](./tools/index.md):

- [dotnet build](./tools/dotnet-build.md)
- [dotnet clean](./tools/dotnet-clean.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/core/tools/dotnet-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The *package store manifest file* is an XML file that contains the list of packa

`-r|--runtime <RUNTIME_IDENTIFIER>`

The runtime identifier to target.
The [runtime identifier](../rid-catalog.md) to target.

## Optional options

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
---
title: "Null-conditional Operators (C# and Visual Basic)"
ms.date: 07/20/2015
ms.date: 04/03/2015
ms.prod: .net
ms.technology:
- "devlang-csharp"
ms.topic: "article"
dev_langs:
- "csharp"
- "vb"
helpviewer_keywords:
- "null-conditional operators [C#]"
- "null-conditional operators [Visual Basic]"
- "?. operator [C#]"
- "?. operator [Visual Basic]"
- "?[] operator [C#]"
- "?[] operator [Visual Basic]"
ms.assetid: 9c7b2c8f-a785-44ca-836c-407bfb6d27f5
caps.latest.revision: 3
author: "BillWagner"
ms.author: "wiwagn"
---
# Null-conditional Operators (C# and Visual Basic)
Used to test for null before performing a member access (`?.`) or index (`?[`) operation. These operators help you write less code to handle null checks, especially for descending into data structures.
# ?. and ?[] null-conditional Operators (C# and Visual Basic)
Used to test for null before performing a member access (`?.`) or index (`?[]`) operation. These operators help you write less code to handle null checks, especially for descending into data structures.

```csharp
int? length = customers?.Length; // null if customers is null
Expand All @@ -25,16 +35,16 @@ Dim first as Customer = customers?(0) ' null if customers is null
Dim count as Integer? = customers?(0)?.Orders?.Count() ' null if customers, the first customer, or Orders is null
```

The last example demonstrates that the null-condition operators are short-circuiting. If one operation in a chain of conditional member access and index operation returns null, then the rest of the chain’s execution stops. Other operations with lower precedence in the expression continue. For example, `E` in the following executes in the second line, and the `??` and `==` operations execute. In the first line, the `??` short circuits and `E` does not execute when the left side evaluates to non-null.
The null-condition operators are short-circuiting. If one operation in a chain of conditional member access and index operation returns null, then the rest of the chain’s execution stops. In the following example, `E` doesn't execute if `A`, `B`, or `C` evaluates to null.

```csharp
A?.B?.C?[0] ?? E
A?.B?.C?[0] == E
A?.B?.C?.Do(E);
A?.B?.C?[E];
```

```vb
A?.B?.C?(0) ?? E
A?.B?.C?(0) == E
A?.B?.C?.Do(E);
A?.B?.C?(E);
```

Another use for the null-condition member access is invoking delegates in a thread-safe way with much less code. The old way requires code like the following:
Expand Down Expand Up @@ -63,7 +73,7 @@ PropertyChanged?.Invoke(e)

The new way is thread-safe because the compiler generates code to evaluate `PropertyChanged` one time only, keeping the result in a temporary variable.

You need to explicitly call the `Invoke` method because there is no null-conditional delegate invocation syntax `PropertyChanged?(e)`. There were too many ambiguous parsing situations to allow it.
You need to explicitly call the `Invoke` method because there is no null-conditional delegate invocation syntax `PropertyChanged?(e)`.

## Language Specifications
[!INCLUDE[CSharplangspec](~/includes/csharplangspec-md.md)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ Because the Common Language Runtime (CLR) has access to generic type information
|<xref:System.Type.DeclaringMethod%2A>|Returns the generic method that defined the current generic type parameter, or null if the type parameter was not defined by a generic method.|
|<xref:System.Type.MakeGenericType%2A>|Substitutes the elements of an array of types for the type parameters of the current generic type definition, and returns a <xref:System.Type> object representing the resulting constructed type.|

In addition, new members are added to the <xref:System.Reflection.MethodInfo> class to enable run-time information for generic methods. See the <xref:System.Reflection.MethodInfo.IsGenericMethod%2A> property remarks for a list of invariant conditions for terms used to reflect on generic methods.
In addition, members of the <xref:System.Reflection.MethodInfo> class enable run-time information for generic methods. See the <xref:System.Reflection.MethodBase.IsGenericMethod%2A> property remarks for a list of invariant conditions for terms used to reflect on generic methods.

|System.Reflection.MemberInfo Member Name|Description|
|----------------------------------------------|-----------------|
|<xref:System.Reflection.MethodInfo.IsGenericMethod%2A>|Returns true if a method is generic.|
|<xref:System.Reflection.MethodBase.IsGenericMethod%2A>|Returns true if a method is generic.|
|<xref:System.Reflection.MethodInfo.GetGenericArguments%2A>|Returns an array of Type objects that represent the type arguments of a constructed generic method or the type parameters of a generic method definition.|
|<xref:System.Reflection.MethodInfo.GetGenericMethodDefinition%2A>|Returns the underlying generic method definition for the current constructed method.|
|<xref:System.Reflection.MethodInfo.ContainsGenericParameters%2A>|Returns true if the method or any of its enclosing types contain any type parameters for which specific types have not been supplied.|
|<xref:System.Reflection.MethodInfo.IsGenericMethodDefinition%2A>|Returns true if the current <xref:System.Reflection.MethodInfo> represents the definition of a generic method.|
|<xref:System.Reflection.MethodBase.ContainsGenericParameters%2A>|Returns true if the method or any of its enclosing types contain any type parameters for which specific types have not been supplied.|
|<xref:System.Reflection.MethodBase.IsGenericMethodDefinition%2A>|Returns true if the current <xref:System.Reflection.MethodInfo> represents the definition of a generic method.|
|<xref:System.Reflection.MethodInfo.MakeGenericMethod%2A>|Substitutes the elements of an array of types for the type parameters of the current generic method definition, and returns a <xref:System.Reflection.MethodInfo> object representing the resulting constructed method.|

## See Also
Expand Down
34 changes: 19 additions & 15 deletions docs/framework/data/adonet/connection-string-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Each .NET Framework data provider has a `Connection` object that inherits from <
- <xref:System.Data.OracleClient.OracleConnectionStringBuilder>

The connection string builders allow you to construct syntactically valid connection strings at run time, so you do not have to manually concatenate connection string values in your code. For more information, see [Connection String Builders](../../../../docs/framework/data/adonet/connection-string-builders.md).

## Windows Authentication
We recommend using Windows Authentication (sometimes referred to as *integrated security*) to connect to data sources that support it. The syntax employed in the connection string varies by provider. The following table shows the Windows Authentication syntax used with the .NET Framework data providers.

Expand All @@ -54,9 +54,13 @@ Each .NET Framework data provider has a `Connection` object that inherits from <
> `Integrated Security=true` throws an exception when used with the `OleDb` provider.

## SqlClient Connection Strings
The syntax for a <xref:System.Data.SqlClient.SqlConnection> connection string is documented in the <xref:System.Data.SqlClient.SqlConnection.ConnectionString%2A?displayProperty=nameWithType> property. You can use the <xref:System.Data.SqlClient.SqlConnection.ConnectionString%2A> property to get or set a connection string for a SQL Server database. If you need to connect to an earlier version of SQL Server, you must use the .NET Framework Data Provider for OleDb (<xref:System.Data.OleDb>). Most connection string keywords also map to properties in the <xref:System.Data.SqlClient.SqlConnectionStringBuilder>.

Each of the following forms of syntax will use Windows Authentication to connect to the **AdventureWorks** database on a local server.
The syntax for a <xref:System.Data.SqlClient.SqlConnection> connection string is documented in the <xref:System.Data.SqlClient.SqlConnection.ConnectionString%2A?displayProperty=nameWithType> property. You can use the <xref:System.Data.SqlClient.SqlConnection.ConnectionString%2A> property to get or set a connection string for a SQL Server database. If you need to connect to an earlier version of SQL Server, you must use the .NET Framework Data Provider for OleDb (<xref:System.Data.OleDb>). Most connection string keywords also map to properties in the <xref:System.Data.SqlClient.SqlConnectionStringBuilder>.

> [!IMPORTANT]
> The default setting for the `Persist Security Info` keyword is `false`. Setting it to `true` or `yes` allows security-sensitive information, including the user ID and password, to be obtained from the connection after the connection has been opened. Keep `Persist Security Info` set to `false` to ensure that an untrusted source does not have access to sensitive connection string information.

### Windows authentication with SqlClient
Each of the following forms of syntax uses Windows Authentication to connect to the **AdventureWorks** database on a local server.

```
"Persist Security Info=False;Integrated Security=true;
Expand All @@ -67,26 +71,26 @@ Each .NET Framework data provider has a `Connection` object that inherits from <
database=AdventureWorks;server=(local)"
```

### SQL Server Logins
### SQL Server authentication with SqlClient
Windows Authentication is preferred for connecting to SQL Server. However, if SQL Server Authentication is required, use the following syntax to specify a user name and password. In this example, asterisks are used to represent a valid user name and password.

```
"Persist Security Info=False;User ID=*****;Password=*****;Initial Catalog=AdventureWorks;Server=MySqlServer"
```

> [!IMPORTANT]
> The default setting for the `Persist Security Info` keyword is `false`. Setting it to `true` or `yes` allows security-sensitive information, including the user ID and password, to be obtained from the connection after the connection has been opened. Keep `Persist Security Info` set to `false` to ensure that an untrusted source does not have access to sensitive connection string information.

To connect to a named instance of SQL Server, use the *server name\instance name* syntax.

When you connect to Azure SQL Database or to Azure SQL Data Warehouse and provide a login in the format `user@servername`, make sure that the `servername` value in the login matches the value provided for `Server=`.

> [!NOTE]
> Windows authentication takes precedence over SQL Server logins. If you specify both Integrated Security=true as well as a user name and password, the user name and password will be ignored and Windows authentication will be used.

### Connect to a named instance of SQL Server
To connect to a named instance of SQL Server, use the *server name\instance name* syntax.

```
Data Source=MySqlServer\MSSQL1;"
```

You can also set the <xref:System.Data.SqlClient.SqlConnectionStringBuilder.DataSource%2A> property of the `SqlConnectionStringBuilder` to the instance name when building a connection string. The <xref:System.Data.SqlClient.SqlConnection.DataSource%2A> property of a <xref:System.Data.SqlClient.SqlConnection> object is read-only.

> [!NOTE]
> Windows authentication takes precedence over SQL Server logins. If you specify both Integrated Security=true as well as a user name and password, the user name and password will be ignored and Windows authentication will be used.

You can also set the <xref:System.Data.SqlClient.SqlConnectionStringBuilder.DataSource%2A> property of the `SqlConnectionStringBuilder` to the instance name when building a connection string. The <xref:System.Data.SqlClient.SqlConnection.DataSource%2A> property of a <xref:System.Data.SqlClient.SqlConnection> object is read-only.

### Type System Version Changes
The `Type System Version` keyword in a <xref:System.Data.SqlClient.SqlConnection.ConnectionString%2A?displayProperty=nameWithType> specifies the client-side representation of [!INCLUDE[ssNoVersion](../../../../includes/ssnoversion-md.md)] types. See <xref:System.Data.SqlClient.SqlConnection.ConnectionString%2A?displayProperty=nameWithType> for more information about the `Type System Version` keyword.
Expand Down
39 changes: 2 additions & 37 deletions docs/framework/data/adonet/sql/filestream-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ namespace FileStreamTest
string path = reader.GetString(0);
byte[] transactionContext = reader.GetSqlBytes(1).Buffer;

using (Stream fileStream = new SqlFileStream(path, transactionContext, FileAccess.Write, FileOptions.SequentialScan, allocationSize: 0))
using (Stream fileStream = new SqlFileStream(path, transactionContext, FileAccess.ReadWrite, FileOptions.SequentialScan, allocationSize: 0))
{
// Seek to the end of the file
fileStream.Seek(0, SeekOrigin.End);
Expand All @@ -172,42 +172,7 @@ namespace FileStreamTest

}
}
} using (SqlConnection connection = new SqlConnection(
connStringBuilder.ToString()))
{
connection.Open();

SqlCommand command = new SqlCommand("", connection);
command.CommandText = "select Top(1) Photo.PathName(), "
+ "GET_FILESTREAM_TRANSACTION_CONTEXT () from employees";

SqlTransaction tran = connection.BeginTransaction(
System.Data.IsolationLevel.ReadCommitted);
command.Transaction = tran;

using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
// Get the pointer for file
string path = reader.GetString(0);
byte[] transactionContext = reader.GetSqlBytes(1).Buffer;

FileStream fileStream = new SqlFileStream(path,
(byte[])reader.GetValue(1),
FileAccess.ReadWrite,
FileOptions.SequentialScan, 0);

// Seek to the end of the file
fs.Seek(0, SeekOrigin.End);

// Append a single byte
fileStream.WriteByte(0x01);
fileStream.Close();
}
}
tran.Commit();
}
}
```

For another sample, see [How to store and fetch binary data into a file stream column](http://www.codeproject.com/Articles/32216/How-to-store-and-fetch-binary-data-into-a-file-str).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ ms.workload:

<a name="is_this_a_generic_type_or_method"></a>
## Is This a Generic Type or Method?
When you use reflection to examine an unknown type, represented by an instance of <xref:System.Type>, use the <xref:System.Type.IsGenericType%2A> property to determine whether the unknown type is generic. It returns `true` if the type is generic. Similarly, when you examine an unknown method, represented by an instance of the <xref:System.Reflection.MethodInfo> class, use the <xref:System.Reflection.MethodInfo.IsGenericMethod%2A> property to determine whether the method is generic.
When you use reflection to examine an unknown type, represented by an instance of <xref:System.Type>, use the <xref:System.Type.IsGenericType%2A> property to determine whether the unknown type is generic. It returns `true` if the type is generic. Similarly, when you examine an unknown method, represented by an instance of the <xref:System.Reflection.MethodInfo> class, use the <xref:System.Reflection.MethodBase.IsGenericMethod%2A> property to determine whether the method is generic.

### Is This a Generic Type or Method Definition?
Use the <xref:System.Type.IsGenericTypeDefinition%2A> property to determine whether a <xref:System.Type> object represents a generic type definition, and use the <xref:System.Reflection.MethodInfo.IsGenericMethodDefinition%2A> method to determine whether a <xref:System.Reflection.MethodInfo> represents a generic method definition.
Use the <xref:System.Type.IsGenericTypeDefinition%2A> property to determine whether a <xref:System.Type> object represents a generic type definition, and use the <xref:System.Reflection.MethodBase.IsGenericMethodDefinition%2A> method to determine whether a <xref:System.Reflection.MethodInfo> represents a generic method definition.

Generic type and method definitions are the templates from which instantiable types are created. Generic types in the .NET Framework class library, such as <xref:System.Collections.Generic.Dictionary%602>, are generic type definitions.

### Is the Type or Method Open or Closed?
A generic type or method is closed if instantiable types have been substituted for all its type parameters, including all the type parameters of all enclosing types. You can only create an instance of a generic type if it is closed. The <xref:System.Type.ContainsGenericParameters%2A?displayProperty=nameWithType> property returns `true` if a type is open. For methods, the <xref:System.Reflection.MethodInfo.ContainsGenericParameters%2A?displayProperty=nameWithType> method performs the same function.
A generic type or method is closed if instantiable types have been substituted for all its type parameters, including all the type parameters of all enclosing types. You can only create an instance of a generic type if it is closed. The <xref:System.Type.ContainsGenericParameters%2A?displayProperty=nameWithType> property returns `true` if a type is open. For methods, the <xref:System.Reflection.MethodBase.ContainsGenericParameters%2A?displayProperty=nameWithType> method performs the same function.

[Back to top](#top)

Expand Down Expand Up @@ -146,7 +146,7 @@ generic<typename V, typename W> ref class D : B<int, V> {};

<a name="invariants"></a>
## Invariants
For a table of the invariant conditions for common terms in reflection for generic types, see <xref:System.Type.IsGenericType%2A?displayProperty=nameWithType>. For additional terms relating to generic methods, see <xref:System.Reflection.MethodInfo.IsGenericMethod%2A?displayProperty=nameWithType>.
For a table of the invariant conditions for common terms in reflection for generic types, see <xref:System.Type.IsGenericType%2A?displayProperty=nameWithType>. For additional terms relating to generic methods, see <xref:System.Reflection.MethodBase.IsGenericMethod%2A?displayProperty=nameWithType>.

[Back to top](#top)

Expand Down
Loading