This section is about how to find quality information about programming on the Web.
The definitive resource for getting help with Microsoft developer tools and platforms used to be Microsoft Developer Network (MSDN). Now, it is Microsoft Docs: https://docs.microsoft.com/
Visual Studio 2017 is integrated with MSDN and Docs, so if you press F1 inside a C# keyword or type, then it will open your browser and take you to the official documentation.
Another useful keystroke in both Visual Studio 2017 and Visual Studio Code is F2. This will show what the public definition of the type looks like by reading the metadata in the compiled assembly. Some tools will even reverse-engineer from the metadata and IL code back into C# for you.
Enter the following code, click inside int
, and then press F2 (or right-click and choose Go To Definition):
int z;
In the new code window that appears, you can see that int
is in the mscorlib.dll
assembly; it is named Int32
; it is in the System
namespace; and int
is therefore an alias for System.Int32
, as shown in the following screenshot:
Microsoft defined int
using a struct
keyword, meaning that int
is a value type stored on the stack. You can also see that int
implements interfaces such as IComparable
and has constants for its maximum and minimum values.
In the code editor window, scroll down to find the Parse
methods and in Visual Studio 2017, you will need to click on the small box with a plus symbol in them to expand the code like I have done in the following screenshot:
In the comment, you will see that Microsoft has documented what exceptions might occur if you call this method (ArgumentNullException
, FormatException
, and OverflowException
).
Now, we know that we need to wrap a call to this method in a try
statement and which exceptions to catch.
StackOverflow is the most popular third-party website for getting answers to difficult programming questions. It is so popular that search engines such as DuckDuckGo have a special way to write a query to search the site.
Go to DuckDuckGo.com and enter the following query:
!so securestring
You will get the following results:
You can search Google with advanced search options to increase the likelihood of finding what you need.
For example, if you are searching for information about garbage collection using a simple Google query, you will see a Wikipedia definition of garbage collection in computer science, and then a list of garbage collection services in your local area, as shown in the following screenshot:
We can improve the search by restricting it to a useful site such as StackOverflow, as shown in the following screenshot:
We can improve the search even more by removing languages that we might not care about like C++, as shown in the following screenshot:
An excellent blog to subscribe to, to keep up-to-date with .NET is the official .NET Blog written by the .NET engineering teams. The .NET Blog has a tag, Week in .NET, which is a summary of interesting news that has happened in the world of .NET in the previous week:
A design pattern is a general solution to a common problem. Programmers have been solving the same problems over and over. When the community discovers a good reusable solution, we call it a design pattern. Many design patterns have been documented over the years.
Navigate to the following link to read about common design patterns: https://en.wikipedia.org/wiki/Software_design_pattern#Classification_and_list
Microsoft has a group called patterns & practices that specializes in documenting and promoting design patterns for Microsoft products.
One of the most common patterns is the Singleton. Examples of Singleton in .NET are the Console
and Math
types.
Read more about the Singleton pattern: https://en.wikipedia.org/wiki/Singleton_pattern
3.145.70.38