.NET Array Dictionary List String 2D Async DataTable Dates DateTime Enum File For Foreach Format IEnumerable If IndexOf Lambda LINQ Parse Path Process Property Regex Replace Sort Split Static StringBuilder Substring Switch Tuple

C#
Net

Framework. A program does not exist alone. It relies on many other programs. In 2002 the .NET Framework was released. In our C# programs, we use keywords to access its types.


Examples

C# keywords. Some keywords (for, if and return) are reserved. This means they are used only in one way. And others (like using) have multiple meanings.

abstractasascendingasyncawaitbaseboolbreakbytecasecatchcharcheckedclassconstcontinuedecimaldefaultdelegatedescendingdodoubledynamicelseenumequalseventexplicitexternfalsefinallyfixedfloatforforeachfromgetgotogroupifimplicitinintinterfaceinternalisjoinletlocklongnamespacenewnullobjectoperatororderbyoutoverrideparamsprivateprotectedpublicreadonlyrefreturnsbytesealedselectsetshortsizeofstackallocstaticstringstructswitchthisthrowtruetrytypeofuintulonguncheckedunsafeushortusingvaluevarvirtualvoidvolatilewherewhileyield
Dictionary

Types. With keywords our code acts upon types. The language is a way to specify these types, combine them, test them. This list contains some of the most helpful types.

ArrayListBufferConsoleDataRowDataSetDataTableDataViewDictionaryDirectoryEnvironmentExceptionFileFileInfoHashtableIComparableIEnumerableKeyValuePairListMathObjectPathProcessRandomRegexSqlClientSqlConnectionSqlParameterStopwatchStreamReaderStreamWriterStringStringBuilderThreadTimerTimeSpanTupleXElementXmlReaderXmlWriter
Maze, contains complexity

Directives. These can turn a program into an incomprehensible mess, a tangle of logic. But #define and #if and #region often have utility in complex programs.

Directives
Class

Classes. Most things in C# involve objects. A string is an object. With a class, we create a type that when instantiated becomes an object.

ClassClass: AttributeClass: Casts, ConversionsClass: CollectionsClass: Constructor
Method

Methods. In structured programming, we divide logical operations into separate methods. In the C# language, we use modifiers to specify method types.

Methods
Numbers

Numbers. In computers, bits represent numbers at a low level.
We can add,
subtract,
multiply
and divide numbers. We can even shift their bits.

NumbersNumbers: Casts
Interface

Interfaces. Programs tend to become complex. With an interface, we can invoke common functionality on many different classes. This keeps our code clearer.

Interface
Read and write

Files. The types StreamReader and File are used to handle files. For special formats like HTML, additional types are available. Some methods are faster.

FilesFiles: HTML
Go copyright

Intermediate language. This is a tedious page. It describes the IL that C# programs are transformed into. This is helpful for advanced developers.

IL
Cover-logo

Visual Studio. The C# language is a recognized standard. But Visual Studio makes this language easy to use. I offer some tips on VS.

Visual StudioDebug
ASP header

ASP.NET. With this framework, we generate and send pages (or other data) to users on a network. ASP.NET has many capabilities. We use it with the C# language.

ASP.NET
DataGridView

Windows Forms. This is a framework for the creation of Windows user interfaces. We can run these programs on nearly any Windows operating system, like Windows 8.

Windows Forms
WPF: Windows Presentation Foundation

WPF, Windows Presentation Foundation, is an advanced user interface toolkit. It works as a replacement for Windows Forms. We control programs with C# code.

WPF
Console

Console. Many programs can be written as console programs. These do not provide elaborate interfaces to the user. There is no need to bother with interface widgets.

Console
Join objects together

Threads. A C# program by default is single-threaded. With System.Threading, we add threads. We start and join them. This adds complexity.

Threads
Drawing: Starry Night

Drawing. Shapes and colors do not come out of thin air. Instead we use the System.Drawing namespace to create them in code. This provides no advanced effects.

Drawing
Reflection

Reflection. Metadata is a relational database. It contains many types. With reflection a program can inspect and act upon them. The syntax here is confusing.

Reflection
Compression

Compression. The .NET Framework supports compression algorithms, like GZIP, in the System.IO.Compression namespace. We can use GZipStream to handle compressed byte arrays.

Compression
Using-keyword

System. Many of the most common types in the .NET Framework are located in the System namespace. Most C# files include the System namespace at the top.

Using System
Garbage collection visualization

Memory. The .NET Framework provides a garbage-collected heap. But this does not erase the benefits of observing and optimizing memory usage.

GC.CollectWeakReference

Memory of types:We measure decimal types, nullable types, strings and reference and value types in general.

Memory: DecimalMemory: NullableMemory: String

Memory of arrays:How much memory do arrays use? I attempt to answer this question with benchmarks.

Array MemoryArray Memory: OptimizationArray Memory: Bools
Using-keyword

Dispose. The using statement ensures memory is released as soon as possible. It invokes the Dispose method in the underlying implementation.

Using
Hypertext transfer protocol: HTTP

Network. We access networking functionality in System.Net. The classes include System.Dns, which resolves DNS addresses. We also access the System.WebClient class, which downloads files.

DnsWebClientHttpClient
ProfileOptimization

Performance. I think performance is important. The developers behind the .NET Framework think so too. Microsoft's teams are careful to maintain good performance.

Performance BenchmarkProfileOptimization
Compiler

Tools. As developers, we build upon the works of many others.
Every program involves,
indirectly,
many millions of lines of code. Many tools are useful for testing .NET programs.

Compiler:The C# compiler is a work of art. It outputs correct and fast IL code. It reports errors.

Compiler

Utilities:Even a great developer sometimes needs some help. Tools like FxCop can catch troublesome problems.

FxCopIL DisassemblerProcess Explorer
Copyright

Concepts. Let us consider the big picture. Software performance is largely determined by how different levels in the memory hierarchy vary in access times.

Memory HierarchyLocality: temporalLocality: reference location
Syntax

Syntax hints. A question mark can mean a ternary statement, or a nullable type. A period can mean a member access or a floating-point number. Here are some syntax hints.

# (Directive): (Inheritance)% (Modulo)? (Nullable)D (Numeric suffix)? (Ternary)* (Unsafe)@ (Verbatim literal)=> (Lambda)?? (Null coalescing)[A] (Attribute){0} (Format)<T> (Generic)

Many parts. The .NET Framework has many parts. It includes the infrastructure upon which C# and VB.NET can be written and compiled. It also provides the runtime.