.NET Development Foundation/Globalization

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Globalization, Drawing, and Text manipulation

Globalization, Drawing, and Text manipulation[edit | edit source]

Exam objective: Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Topics[edit | edit source]

Globalization[edit | edit source]

Drawing[edit | edit source]

Text manipulation[edit | edit source]

Text manipulation, in the context of the exam objectives, covers 3 main subjects: string building, regular expressions and text encoding. We look at each in the following paragraphs.

String and StringBuilder classes[edit | edit source]

Text manipulation starts with the representation of a string which is done via the String class. No specific exam objective mentions the String class but we added a section for it because you must understand some of its specific characteristics.

Next comes the StringBuilder class that serves for efficient construction.

Regular expressions[edit | edit source]

The Regex, Match and Group classes together implement the regular expressions support in the .NET framework.

Regular expressions are a world by themselves and have been around for quite some time.

There is a wikibook on regular expressions which, among other things, point to this Tutorial.

Regular expressions support in .NET basically allows for:

  • testing the match of a string to a regex pattern (Regex.IsMatch method)
  • extracting the substrings that "match" part of a pattern (Regex.Match method with Match and Group classes).
Text encoding[edit | edit source]

Classes, Interfaces, and tools[edit | edit source]

Format data based on culture information.[edit | edit source]

(Refer System.Globalization namespace)

Access culture and region information[edit | edit source]

Exam objective: Access culture and region information in a .NET Framework application

CultureInfo class - MSDN

CultureTypes enumeration - MSDN

RegionInfo class - MSDN

Format date and time values based on the culture.[edit | edit source]

DateTimeFormatInfo class - MSDN

Format number values based on the culture.[edit | edit source]

NumberFormatInfo class - MSDN

NumberStyles enumeration - MSDN

Perform culture-sensitive string comparison.[edit | edit source]

CompareInfo class - MSDN

CompareOptions enumeration - MSDN

Custom culture[edit | edit source]

Exam objective: Build a custom culture class based on existing culture and region classes

CultureAndRegionInfoBuilder class - MSDN

CultureAndRegionModifier enumeration - MSDN

System.Drawing namespace[edit | edit source]

Exam objective: Enhance the user interface of a .NET Framework application by using the System.Drawing namespace.

Brushes, Pens, Colors and Fonts[edit | edit source]

Exam objective: Enhance the user interface of a .NET Framework application by using brushes, pens, colors, and fonts

Brush class - MSDN

Brushes class - MSDN

SystemBrushes class - MSDN

TextureBrush class - MSDN

Pen class - MSDN

Pens class - MSDN

SystemPens class - MSDN

SolidBrush class - MSDN

Color structure - MSDN

ColorConverter class - MSDN

ColorTranslator class - MSDN

SystemColors class - MSDN

StringFormat class - MSDN

Font class - MSDN

FontConverter class - MSDN

FontFamily class - MSDN

SystemFonts class - MSDN

Graphics, Images, Bitmaps and Icons[edit | edit source]

Exam objective: Enhance the user interface of a .NET Framework application by using graphics, images, bitmaps, and icons

Graphics class - MSDN

BufferedGraphics class - MSDN

BufferedGraphicsManager class - MSDN

Image class - MSDN

ImageConverter class - MSDN

ImageAnimator class - MSDN

Bitmap class - MSDN

Icon class - MSDN

IconConverter class - MSDN

SystemIcons class - MSDN

Shapes and Sizes[edit | edit source]

Exam objective: Enhance the user interface of a .NET Framework application by using shapes and sizes

Point Structure - MSDN

PointConverter class - MSDN

Rectangle Structure - MSDN

RectangleConverter class - MSDN

Size Structure - MSDN

SizeConverter class - MSDN

Region class - MSDN

Text handling and regular expressions[edit | edit source]

Exam objective: Enhance the text handling capabilities of a .NET Framework application, and search, modify, and control text in a .NET Framework application by using regular expressions

(Refer System.Text namespace)

(Refer System.RegularExpressions namespace)

String class[edit | edit source]

The String class is not a specific exam objective but was added to have a place to discuss some of its characteristics.

String class - MSDN

StringBuilder class[edit | edit source]

The StringBuilder class is used for very fast string concatenation. If you use conventional string concatenation then it will run very slow because a string is held in an array. Each concatenation causes the array to increase its size and the memory has to be copied to a new location internally. This is very slow.

For fast string concatenations use StringBuilder instead. It is about 1000 times faster (depending on the string you concatenate).

StringBuilder class - MSDN

Refer to the example to measure the performance differences.

C# example

StringBuilder example

using System;
using System.Collections;
public class Demo
    public static void Main()
        const int len = 30;
        const int loops = 5000;
        DateTime timeStart, timeStop;
        // Measure time for normal string concatenation
        timeStart = DateTime.Now;
        string str = "";
        for (int i = 0; i < loops; i++)
            str += new String('x', len);
        timeStop = DateTime.Now;
        int millis = timeStop.Subtract(timeStart).Milliseconds;
        Console.WriteLine("Duration for " + loops + " loops: " + millis + " ms");
        // Measure time for StringBuilder string concatenation
        StringBuilder sb = new StringBuilder();
        timeStart = DateTime.Now;
        for (int i = 0; i < loops; i++)
            sb.Append(new String('x', len));
        str = sb.ToString();
        timeStop = DateTime.Now;
        millis = timeStop.Subtract(timeStart).Milliseconds;
        Console.WriteLine("Duration for " + loops + " loops: " + millis + " ms");
Regex class[edit | edit source]

Regex class - MSDN

Match class and MatchCollection class[edit | edit source]

Match class - MSDN

MatchCollection class - MSDN

Group class and GroupCollection class[edit | edit source]

Group class - MSDN

GroupCollection class - MSDN

Encode text by using Encoding classes[edit | edit source]

Encoding class - MSDN

EncodingInfo class - MSDN

ASCIIEncoding class - MSDN

UnicodeEncoding class - MSDN

UTF8Encoding class - MSDN

Encoding Fallback classes - MSDN

Decode text by using Decoding classes.[edit | edit source]

Decoder class - MSDN

Decoder Fallback classes - MSDN

Capture class and CaptureCollection class[edit | edit source]

Capture class - MSDN

CaptureCollection class - MSDN