C# – String Builder

String Builder System.Text represents a mutable string. Most popular usage of string builder is to concatenate strings. To clear contents of string builder, instantiate or set its length to zero. Functions Method Description Append Insert Remove Replace AppendLine Appends and adds a newline sequence AppendFormat Accepts composite format string Length Length of string StringBuilder sb […]

C# – String and Text Handling

String and Text Handling Char char represent a single Unicode character and alias the System.Char struct. // char literals: char c = ‘A’; char newLine = ‘\n’; System.Char defines a range of static methods for working with characters Console.WriteLine (char.ToUpper (‘c’)); // C Console.WriteLine (char.IsWhiteSpace (‘\t’)); // True Console.WriteLine (char.IsLetter (‘x’)); // True Console.WriteLine (char.GetUnicodeCategory […]

C# – XML Documentation

XML Documentation A documentation comment is a piece of embedded XML that documents a type or member. A documentation comment comes immediately before a type or member declaration and starts with three slashes, it can have single or multi line comments. Standard XML Documentation Tags <summary>…</summary> Indicates the tool tip that IntelliSense should display for […]

C# – Preprocessor Directives

Preprocessor Directives Preprocessor directives supply the compiler with additional information about regions of code. The most common preprocessor directives are the conditional directives, which provide a way to include or exclude regions of code from compilation. In this class, the statement in Foo is compiled as conditionally dependent upon the presence of the DEBUG symbol. […]

C# – Unsafe Code and Pointers

Unsafe Code and Pointers C# supports direct memory manipulation via pointers within blocks of code marked unsafe and compiled with the /unsafe compiler option. Pointer Basics A pointer instance holds the address of a variable. Pointer types can be (unsafely) cast to any other pointer type. & The address-of operator returns a pointer to the […]

C# – Attributes

Attributes Attributes are an extensible mechanism for adding custom information to code elements (assemblies, types, members, return values, parameters, and generic type parameters). This extensibility is useful for services that integrate deeply into the type system, without requiring special keywords or constructs in the C# language. Example: serialization – the process of converting arbitrary objects […]

C# – Anonymous Types

Anonymous Types Anonymous type is a simple class created by the compiler on the fly to store a set of values. It is created using the new keyword followed by an object initializer, specifying the properties and values. You must use the var keyword to reference an anonymous type. Anonymous types are used mostly when […]

C# – New

New Operator/Modifier/Constraint new keyword can be used for operator, modifier, constraint. New Operator 1. Is used to create objects and invoke constructors. Class1 obj = new Class1(); 2. Used to create instances of anonymous types. var query = from cust in customers select new { Name = cust.Name, Address = cust.PrimaryAddress }; 3. Is used […]

C# – Command Prompt

Using Visual Studio Command Prompt Compiling files togehter csc /t:exe /out:MyProgram.exe MyMainClass.cs MyClass.cs or csc /t:exe /out:MyProgram.exe *.cs

C# – List of Articles

List of Articles A Attributes Anonymous Types Abstract Access Modifiers Arrays B Base keyword C Command Prompt Collections Casting and Reference Conversions Constant Constructors Class Classes and Objects Conversions Constructors and Instantiation D Dates and Times Delegates Difference between ref and out parameters E Encapsulation Equality Comparison Extension Methods Enumeration and Iterators Events Enums Enumerable […]