You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/csharp/getting-started/debugging-with-visual-studio-2017.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,9 +119,9 @@ Visual Studio also allows us to step line by line through a program and monitor
119
119
120
120
1. Choose **Debug**, **Step Into**, or press the F11 key. Visual Studio hightlights the statement that includes the `name` variable assignment. The **Autos** window shows that `name` is `null`, and the console window displays the string "What is your name?".
121
121
122
-
1. Respond to the prompt by entering a string in the console window and pressing Enter. The console will be unresponsive, and the string you enter won't be displayed in the console window, but the [Console.ReadLine](xref:System.Console.ReadLine()) method will nevertheless capture your input.
122
+
1. Respond to the prompt by entering a string in the console window and pressing Enter. The console will be unresponsive, and the string you enter won't be displayed in the console window, but the [Console.ReadLine](xref:System.Console.ReadLine) method will nevertheless capture your input.
123
123
124
-
1. Choose **Debug**, **Step Into**, or press the F11 key. Visual Studio highlights the statement that includes the `date` variable assignment. The **Autos** window shows the [DateTime.Now](xref:System.DateTime.Now) property value and the value returned by the call to the [Console.ReadLine](xref:System.Console.ReadLine()) method. The console window also displays the string entered when the console prompted for input.
124
+
1. Choose **Debug**, **Step Into**, or press the F11 key. Visual Studio highlights the statement that includes the `date` variable assignment. The **Autos** window shows the [DateTime.Now](xref:System.DateTime.Now) property value and the value returned by the call to the [Console.ReadLine](xref:System.Console.ReadLine) method. The console window also displays the string entered when the console prompted for input.
125
125
126
126
1. Choose **Debug**, **Step Into**, or press the F11 key. The **Autos** window now shows the value of the `date` variable after the assignment from the [DateTime.Now](xref:System.DateTime.Now) property. The console window is unchanged.
# Publishing your Hello World application with Visual Studio 2017
17
17
18
-
In [Building a C# Hello World application with .NET Core in VIsual Studio 2017 RC](with-visual-studio-2017.md), you built your Hello World console application, and in [Debugging your C# Hello World application with Visual Studio 2017 RC](debugging-with-visual-studio-2017.md), you tested it using the Visual Studio debugger. Now that you're sure that it works as expected, you an publish it so that other users can run it. Publishing creates the set of files that are needed to run your application; you can deploy them by copying them to a target machine.
18
+
In [Building a C# Hello World application with .NET Core in Visual Studio 2017 RC](with-visual-studio-2017.md), you built your Hello World console application, and in [Debugging your C# Hello World application with Visual Studio 2017 RC](debugging-with-visual-studio-2017.md), you tested it using the Visual Studio debugger. Now that you're sure that it works as expected, you an publish it so that other users can run it. Publishing creates the set of files that are needed to run your application; you can deploy them by copying them to a target machine.
19
19
20
20
Publishing .NET Core console applications from Visual Studio has not yet been implemented in the RC release. It will be implemented in the final release of Visual Studio 2017.
21
21
22
-
You can publish your application using the [dotnet.exe](../../core/tools/dotnet.md) commandline utility. To do this:
22
+
You can publish your application using the [dotnet.exe](../../core/tools/dotnet.md) command-line utility. To do this:
23
23
24
24
1. Open a console window. For example, in the **Ask me anything** text box in the Windows taskbar, enter `Command Prompt`, and then choose the **Command Prompt** desktop app to open the console window.
25
25
26
26
1. Navigate to your library's project directory. Typically, unless you've reconfigured the file location, it is in the `Documents\Visual Studio 2017\Projects\HelloWorld\HelloWorld` directory. The directory contains your source code and a project file, `HelloWorld.csproj`.
27
27
28
-
<!-- Steve, can you check this on your system? I'm sure I didn't do any renaming, but that's the directory I have on minem and I'd expect it to be HelloWorld instead of Hello. -->
29
-
30
28
1. To build a debug build of your application, issue the command `dotnet.exe publish -c debug`. To publish a release build, issue the command `dotnet.exe publish -c release`. It's generally a good idea to create a debug build of your application for additional testing, and to create the release version when testing has ended.
31
29
32
-
[!TIP] If the directory that contains `dotnet.exe` is not in your path, you can find its location by entering `where dotnet.exe` in the console window.
30
+
> [!TIP]
31
+
> If the directory that contains `dotnet.exe` is not in your path, you can find its location by entering `where dotnet.exe` in the console window.
33
32
34
33
For debug versions, the final files are found in the `.\bin\debug\netcoreapp1.0\publish` directory. For release versions, they're found in the `.\bin\release\netcoreapp1.0\publish` directory. You can deploy them to target systems by copying the files generated by the publishing process into a single directory or folder. You do not have to include the `HelloWorld.pdb` file, which contains symbols used for debugging.
Copy file name to clipboardExpand all lines: docs/csharp/misc/cs0415.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,11 +39,11 @@ translation.priority.mt:
39
39
# Compiler Error CS0415
40
40
The 'IndexerName' attribute is valid only on an indexer that is not an explicit interface member declaration
41
41
42
-
This error occurs if you use an IndexerName attribute on an indexer that was an explicit implementation of an interface. This error may be avoided by removing the interface name from the declaration of the indexer, if possible. For more information, see the [IndexerNameAttribute Class](xref:System.Runtime.CompilerServices.IndexerNameAttribute).
42
+
This error occurs if you use an IndexerName attribute on an indexer that was an explicit implementation of an interface. This error may be avoided by removing the interface name from the declaration of the indexer, if possible. For more information, see the [IndexerNameAttribute Class](xref:System.Runtime.CompilerServices.IndexerNameAttribute).
Copy file name to clipboardExpand all lines: docs/csharp/misc/cs0625.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,11 +39,11 @@ translation.priority.mt:
39
39
# Compiler Error CS0625
40
40
'field': instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute
41
41
42
-
When a struct is marked with an explicit **StructLayout** attribute, all fields in the struct must have the [FieldOffset](xref:System.Runtime.InteropServices.FieldOffsetAttribute) attribute. For more information, see [StructLayoutAttribute Class](xref:System.Runtime.InteropServices.StructLayoutAttribute).
42
+
When a struct is marked with an explicit **StructLayout** attribute, all fields in the struct must have the [FieldOffset](xref:System.Runtime.InteropServices.FieldOffsetAttribute) attribute. For more information, see [StructLayoutAttribute Class](xref:System.Runtime.InteropServices.StructLayoutAttribute).
@@ -58,7 +58,8 @@ For many applications, you want to create and manage groups of related objects.
58
58
59
59
-[Iterators](#BKMK_Iterators)
60
60
61
-
## <aname="BKMK_SimpleCollection"></a> Using a Simple Collection
61
+
<aname="BKMK_SimpleCollection"></a>
62
+
## Using a Simple Collection
62
63
The examples in this section use the generic <xref:System.Collections.Generic.List%601> class, which enables you to work with a strongly typed list of objects.
63
64
64
65
The following example creates a list of strings and then iterates through the strings by using a or [foreach](../../../csharp/language-reference/keywords/foreach-in.md) statement.
@@ -186,8 +187,9 @@ public class Galaxy
186
187
publicintMegaLightYears { get; set; }
187
188
}
188
189
```
189
-
190
-
## <aname="BKMK_KindsOfCollections"></a> Kinds of Collections
190
+
191
+
<aname="BKMK_KindsOfCollections"></a>
192
+
## Kinds of Collections
191
193
Many common collections are provided by the .NET Framework. For a complete list, see [collections namespace](System.Collections%20namespaces.xml). Each type of collection is designed for a specific purpose.
192
194
193
195
Some of the common collection classes are described in this section:
You can create a generic collection by using one of the classes in the <xref:System.Collections.Generic> namespace. A generic collection is useful when every item in the collection has the same data type. A generic collection enforces strong typing by allowing only the desired data type to be added.
203
206
204
207
The following table lists some of the frequently used classes of the <xref:System.Collections.Generic?displayProperty=fullName> namespace:
@@ -213,14 +216,16 @@ public class Galaxy
213
216
214
217
For additional information, see [Commonly Used Collection Types](http://msdn.microsoft.com/library/f5d4c6a4-0d7b-4944-a9fb-3b12d9ebfd55), [Selecting a Collection Class](http://msdn.microsoft.com/library/ba049f9a-ce87-4cc4-b319-3f75c8ddac8a), and <xref:System.Collections.Generic?displayProperty=fullName>.
In the .NET Framework 4 or newer, the collections in the <xref:System.Collections.Concurrent> namespace provide efficient thread-safe operations for accessing collection items from multiple threads.
218
222
219
223
The classes in the <xref:System.Collections.Concurrent> namespace should be used instead of the corresponding types in the <xref:System.Collections.Generic?displayProperty=fullName> and <xref:System.Collections?displayProperty=fullName> namespaces whenever multiple threads are accessing the collection concurrently. For more information, see [Thread-Safe Collections](http://msdn.microsoft.com/library/2e7ca21f-786c-4367-96be-0cf3f3dcc6bd) and <xref:System.Collections.Concurrent>.
220
224
221
225
Some classes included in the <xref:System.Collections.Concurrent> namespace are <xref:System.Collections.Concurrent.BlockingCollection%601>, <xref:System.Collections.Concurrent.ConcurrentDictionary%602>, <xref:System.Collections.Concurrent.ConcurrentQueue%601>, and <xref:System.Collections.Concurrent.ConcurrentStack%601>.
The classes in the <xref:System.Collections?displayProperty=fullName> namespace do not store elements as specifically typed objects, but as objects of type `Object`.
225
230
226
231
Whenever possible, you should use the generic collections in the <xref:System.Collections.Generic?displayProperty=fullName> namespace or the <xref:System.Collections.Concurrent> namespace instead of the legacy types in the `System.Collections` namespace.
@@ -235,8 +240,9 @@ public class Galaxy
235
240
|<xref:System.Collections.Stack>|Represents a last in, first out (LIFO) collection of objects.|
236
241
237
242
The <xref:System.Collections.Specialized> namespace provides specialized and strongly typed collection classes, such as string-only collections and linked-list and hybrid dictionaries.
238
-
239
-
## <aname="BKMK_KeyValuePairs"></a> Implementing a Collection of Key/Value Pairs
243
+
244
+
<aname="BKMK_KeyValuePairs"></a>
245
+
## Implementing a Collection of Key/Value Pairs
240
246
The <xref:System.Collections.Generic.Dictionary%602> generic collection enables you to access to elements in a collection by using the key of each element. Each addition to the dictionary consists of a value and its associated key. Retrieving a value by using its key is fast because the `Dictionary` class is implemented as a hash table.
241
247
242
248
The following example creates a `Dictionary` collection and iterates through the dictionary by using a `foreach` statement.
## <aname="BKMK_LINQ"></a> Using LINQ to Access a Collection
349
+
350
+
<aname="BKMK_LINQ"></a>
351
+
## Using LINQ to Access a Collection
345
352
LINQ (Language-Integrated Query) can be used to access collections. LINQ queries provide filtering, ordering, and grouping capabilities. For more information, see [Getting Started with LINQ in C#](../../../csharp/programming-guide/concepts/linq/getting-started-with-linq.md).
346
353
347
354
The following example runs a LINQ query against a generic `List`. The LINQ query returns a different collection that contains the results.
@@ -386,8 +393,9 @@ public class Element
386
393
publicintAtomicNumber { get; set; }
387
394
}
388
395
```
389
-
390
-
## <aname="BKMK_Sorting"></a> Sorting a Collection
396
+
397
+
<aname="BKMK_Sorting"></a>
398
+
## Sorting a Collection
391
399
The following example illustrates a procedure for sorting a collection. The example sorts instances of the `Car` class that are stored in a <xref:System.Collections.Generic.List%601>. The `Car` class implements the <xref:System.IComparable%601> interface, which requires that the <xref:System.IComparable%601.CompareTo%2A> method be implemented.
392
400
393
401
Each call to the <xref:System.IComparable%601.CompareTo%2A> method makes a single comparison that is used for sorting. User-written code in the `CompareTo` method returns a value for each comparison of the current object with another object. The value returned is less than zero if the current object is less than the other object, greater than zero if the current object is greater than the other object, and zero if they are equal. This enables you to define in code the criteria for greater than, less than, and equal.
@@ -464,10 +472,11 @@ public class Car : IComparable<Car>
464
472
}
465
473
```
466
474
467
-
## <aname="BKMK_CustomCollection"></a> Defining a Custom Collection
475
+
<aname="BKMK_CustomCollection"></a>
476
+
## Defining a Custom Collection
468
477
You can define a collection by implementing the <xref:System.Collections.Generic.IEnumerable%601> or <xref:System.Collections.IEnumerable> interface. For additional information, see [How to: Access a Collection Class with foreach](../../../csharp/programming-guide/classes-and-structs/how-to-access-a-collection-class-with-foreach.md).
469
478
470
-
Although you can define a custom collection, it is usually better to instead use the collections that are included in the .NET Framework, which are described in [Kinds of Collections](http://msdn.microsoft.com/library/e76533a9-5033-4a0b-b003-9c2be60d185b) earlier in this topic.
479
+
Although you can define a custom collection, it is usually better to instead use the collections that are included in the .NET Framework, which are described in [Kinds of Collections](#BKMK_KindsOfCollections) earlier in this topic.
471
480
472
481
The following example defines a custom collection class named `AllColors`. This class implements the <xref:System.Collections.IEnumerable> interface, which requires that the <xref:System.Collections.IEnumerable.GetEnumerator%2A> method be implemented.
473
482
@@ -543,8 +552,9 @@ public class Color
543
552
publicstringName { get; set; }
544
553
}
545
554
```
546
-
547
-
## <aname="BKMK_Iterators"></a> Iterators
555
+
556
+
<aname="BKMK_Iterators"></a>
557
+
## Iterators
548
558
An *iterator* is used to perform a custom iteration over a collection. An iterator can be a method or a `get` accessor. An iterator uses a [yield return](../../../csharp/language-reference/keywords/yield.md) statement to return each element of the collection one at a time.
549
559
550
560
You call an iterator by using a [foreach](../../../csharp/language-reference/keywords/foreach-in.md) statement. Each iteration of the `foreach` loop calls the iterator. When a `yield return` statement is reached in the iterator, an expression is returned, and the current location in code is retained. Execution is restarted from that location the next time that the iterator is called.
0 commit comments