#T{background:#fe903c}#W,#B{margin:0 0 100px;flex-wrap:wrap}#A{font-weight:700;color:#06c;user-select:none;cursor:pointer}#W{display:none}#A:hover,a:hover>b{text-decoration:underline}#B{display:flex;background:#d6f5ff}#B>a{flex:25%;font-size:83%;min-width:180px;padding:10px;color:#000}#B>#G{color:#fff;background:#787878}a{font-weight:normal}#C{background:0 0/contain no-repeat;float:left;margin-right:10px}@media(max-width:500px){#A{margin:6px 0;flex:50%}#C{max-width:70px;min-width:70px;max-height:70px;min-height:70px}#B>a{padding:4px}}@media(min-width:501px){#C{max-width:110px;min-width:110px;max-height:110px;min-height:110px}#A{flex:33%;max-width:33%}}`geH0`array`C# Array Examples, String Arrays`Use string arrays: initialize them, loop over them, and access lengths and elements at indexes.`linq`C# LINQ Examples: System Linq and Extensions`Use extension methods, and query syntax, from the System Linq namespace.`list`C# List Examples`Use the List collection. A List is a dynamic array that grows as needed.`static`C# Static Method, Class and Constructor`Use the static keyword. Create static methods, static classes and static constructors.`2d`C# 2D Array Examples`Use 2D arrays: allocate them, loop over them and add to them. A for-loop iterates over 2D array elements.`async`C# Async, Await Examples (Task)`Use async and await keywords, along with a Task. Call an async method with await.`console`C# Console WriteLine (Print)`Call the Console WriteLine method. Print values like ints and strings to the screen.`convert-list-string`C# Convert List to String`Use the string Join method and StringBuilder to convert Lists and strings.`datatable`C# DataTable Examples`Use DataTable to store data in memory from databases and other data sources.`datetime`C# DateTime Examples`Compute date and time values. Get relative dates and call DateTime constructors and properties.`datetime-format`C# DateTime Format`Review DateTime format patterns. Call ToString with format codes like MMMM, dd and hh.`dictionary`C# Dictionary Examples`Use the Dictionary class from System Collections Generic. A Dictionary provides fast lookups.`enum`C# Enum Examples`Use enums to store named and magic constants. An enum can be used in collections, if and switch.`file`C# File Handling`Learn ways to handle files. Many methods from the System IO namespace are available.`for`C# For Loops`Use the for-loop. For includes an index value, a start and end, and has special syntax.`foreach`C# Foreach Loop Examples`Use the foreach-loop to make loops clearer. Other loops, like for and while, are compared.`ienumerable`C# IEnumerable Examples`Use the IEnumerable interface. IEnumerable things can be looped over with foreach.`if`C# if Statement: else if, else`Use the if, else-if and else statements to make logical tests in a method.`indexof`C# IndexOf Examples`Call the IndexOf method. IndexOf returns the first index of specified character or substring.`parse`C# int Parse, TryParse: Convert Strings to Integers`Convert strings into ints with the int Parse and int TryParse methods.`keyvaluepair`C# KeyValuePair Examples`Use KeyValuePair to loop over a Dictionary with foreach. KeyValuePair has 2 member fields.`keyword`C# Keywords`Review keywords from the C# language. Each keyword has a link to an example and a description.`lambda`C# Lambda Expressions`Use the lambda expression syntax to create function objects. Lambdas have arguments and return values.`path`C# Path Examples`Use the Path class. Path handles file locations in a consistent way, resolving common problems.`process`C# Process Start Examples`Create a Process to start external EXEs. Include the System Diagnostics namespace and call Process Start.`property`C# Property Examples (get, set)`Use properties and create them with the get and set keywords. A property is a method that gets or sets a value.`random`C# Random Number Examples`Get random numbers with the Random class. Random has a Next method and can be used as a field.`reflection`C# Reflection Examples`Learn about the System Reflection namespace. Use FieldInfo, and call GetMethod and GetProperties.`regex`C# Regex Match Examples: Regular Expressions`Use the Regex class and Regex Match. Review features from System Text RegularExpressions.`remove-duplicates-list`C# Remove Duplicates From List`Eliminate duplicate elements from a List. Invoke the Distinct method from System Linq.`replace`C# Replace String Examples`Use the Replace method to change all instances of one substring to another substring. Get the modified string.`sort`C# Sort Examples: Arrays and Lists`Sort arrays using Array Sort and Lists with Sort. Review the performance of sorting.`split`C# Split String Examples`Use the string Split method. Call Split with arguments to separate on newlines, spaces and words.`string`C# String`Explore string methods: create, search and change strings with built-in code.`format`C# String Format`Insert values into a string with string Format. Specify percentages, decimals and padding.`string-switch`C# String Switch Examples`Use a switch statement on a string for improved performance. String literal cases can be tested.`substring`C# Substring Examples`Use the Substring method with start and length ints. Substring gets parts of strings.`switch`C# Switch Examples`Use a switch statement to branch on a constant in an efficient way. Switch on value types and strings.`tuple`C# Tuple Examples`Create tuples to store immutable data. A tuple has multiple fields of different types.`while`C# While Loop Examples`Loop over numbers and indexes with the while-loop. This syntax can be used for infinite loops.`C#`C# (2)`C# (ASP.NET)`C# (Windows)`C# (WPF)`F#`Go`Java`JavaScript`Python`Ruby`Scala`Swift`Swift (iOS)`TensorFlow`VB.NET`Written by Sam Allen, (Dot Net Perls). © 2007-2018 Sam Allen. All rights reserved.`streamwriter`C# StreamWriter Example`Use StreamWriter from System IO to write text files. Place StreamWriter in using statements.`list-remove`C# List Remove, RemoveRange and RemoveAt`Use Remove, RemoveRange and RemoveAt on Lists. Delete elements by value and index.`stringbuilder`C# StringBuilder Examples`Improve string append performance with StringBuilder. Save allocations when building strings.`max`C# Max and Min: Get Highest or Lowest Element`Use Max and Min from System Linq. Get the highest or lowest elements.`datetime-parse`C# DateTime Parse: Convert String to DateTime`Handle strings containing dates with DateTime Parse. Convert a string to a DateTime.`sort-list`C# Sort List With Lambda, Comparison Method`Use lambda expressions and LINQ to sort elements in a List. Call List Sort.