
Loading ...
12. Oktober 2009
Good morning,
today I start with Collections and Dictionaries during my MCTS exam-preparation. As usual I provide my notes on that topic as a little help and motivation for other students.
Collections
- namespaces where we find Collections are System.Collections and System.Collections.Specialized
- Collectionstypes are:
- ArrayList – stores any type of object, expands as required. Accessable by zero based index or within a foreach_loop. Use .Add, .AddRange, .Remove, .Insert and .Sort (Objects need to implement IComparable), .Reverse (Reverse current order)
- Queue – First in, First out (FIFO) collection. Use .Enqueue and .Dequeue to add and remove objects and .Peek to lookup an object on a specified position. Use .Clear to remove all objects
- Stack – Last in, First out (LIFO) collection. Use .Push and .Pop to add and remove objects and .Peek to loopup an object on a specified position. Use .Clear to remove all objects
- StringCollection – As ArrayList, but strongly typed for strings, does not support sorting
- BitArray / BitVector – Collection of boolean values. BitVector is limited to 32 bits, BitArray stores more.
Thinking about IComparable, the method .CompareTo provides default sortorder while .Compare provides custom sortorder.
Dictionaries
Dictionary-Types are:
- Hashtable – name/value pairs that can be retrieved by name and index
- SortedList – sorted automatically by key. Array of DictionaryEntry objects
- StringDictionary – Hashtable that is strongly typed to string
- ListDictionary – Dictionary optimized for less then 10 items
- HybridDictionary – Advantage of ListDictionary when less then 10 items, otherwise behaves like a Hashtable
- NameValueCollection – pairs of strings, accessable by index or name(key). Can store multiple values for the same key.
Veröffentlicht in Allgemein | Keine Kommentare »

Loading ...
09. Oktober 2009
Good Day,
normally I would write about Regular Expressions today, but I need a little bit more preparation on this topic. So I will skip it for now, and work on Encoding and Decoding.
General
- ASCII (American Standard Code for Information Interchange) is the foundation of the encodings
- ASCII is 7 bit (0-127)
- It includes English letters in upper and lower case, punctuation, numbers and some special characters
- It does not include non-English characters
- ANSI defined code pages for different character-sets using 8-bit (0-127 as ASCII, 128-255 special)
- ASCII and ISO 8859 (ANSI) encodings are being replaced by Unicode, a massive code-page
- Default of .NET Framework is Unicode UTF-16 (In some cases UTF-8)
- System.Text namespace contains classes that provide encoding and decoding (UTF-32 encoding, UTF-16 encoding, UTF-8 encoding, ASCII encoding, ANSI/ISO encoding)
- UTF-8 and UTF-7 are backward compatible with ASCII-Encoding, UTF-16 and UTF-32 are not.
Encoding classes
- use System.Text.Encoding.GetEncoding to get a special encoding object
- use Encoding.GetBytes to convert a Unicode string to its byte representation
- To Explore Code Pages use Encoding.GetEncodings to get a list of EncodingInfo Objects which represent available encodings
Specify Encoding when reading or writing a file
- Use the overload of the StreamWriter- and StreamReader-Constructor accepting Encoding-Object
- Typically you don’t need to specify the encoding type when reading a file. Framework detects automatically.
- For Example writing “Hello Kitty!!” to a file has the following sizes when choosing the encoding:
- UTF-7 : 19 bytes
- UTF-8 : 18 bytes
- UTF-16: 32 bytes
- UTF-32: 64 bytes
- Notepad can not read UTF-7 and UTF-32 files correctly
So far for now, next time I learn about Collections and Generics
Veröffentlicht in Allgemein | Keine Kommentare »

Loading ...
06. Oktober 2009
Good Morning folks,
Today I read about streams and files, and as usual I provide my notes as a summary. enjoy !
Textfiles
- To read a textfile, we can use TextReader or StreamReader Class
- To write a textfile, we can use TextWriter or StreamWriter Class
- StreamReader derives from TextReader
- Usually you use File.OpenText or StreamReader Constructor
- Typically we use ReadLine or ReadToEnd Methods to read data
- Dont forget to call Close on the Reader or Writer after finished reading or writing
- To ensure, that no data is left in the buffer while keeping the file open use the Flush Method
Binary Files
- To read and write binary files, use BinaryReader and BinaryWriter
- Generally serialization is more effective
Strings
- Use StringWriter to write data to StringBuilder
- Not used very often, only in special scenarios
MemoryStream
- To create a stream in memory
- Commonly used to store data temporarily that will be written to a file eventually
- To Minimize the time a file is locked open, minimizes the potential for conflict
- MemoryStream often is used with a StreamWriter, cause MS itself has only WriteByte/Write, and ReadByte/Read Methods that work with bytes and byte-arrays
BufferedStream
- Is used for custom stream implements
- .NET Stream Classes have a build-in buffering logic, so you normally dont need to use BufferedStream. If you do so its redundant and inefficent
Compressed Streams
- You can only read or write bytes and byte-arrays directly, but you can use StreamWriter and StreamReader
- Use GZipStream Class for GZIP-Compression and DeflatedStream class for Deflated Data Format
- CompressionMode which is part of the constructor indicates simply if you are compressing or decompressing data
Isolated Storage
- Isolated Storage is a private file system
- It requires fewer privileges than writing to filesystem
- IS is isolated by user, application domain and assembly
- Don’t use to store high-value secrets or sensitive data, because its not protected from high-trusted code, unmanaged code or trusted users of the computer
- The access to a file is restricted to the user who created it
- isolation by application domain is optional
- In most case (almost always) you will use the isolation by application-domain
- Classes to work with Isolated Storage (All in System.IO.IsolatedStorage)
- IsolatedStorageFile – Management of Isolated Storage Stores (Often Used Methods are .GetUserStoreForAssembly, .GetUserStoreForDomain, .GetStore
- IsolatedStorageFileStream – Access to read/write Isolated Storage files
- IsolatedStorageException – exception related to Isolated Sotrage
- Code must be granted IsolatedStorageFilePermission
Tags: Exam 70-536, MCTS
Veröffentlicht in Allgemein, MCTS Examen 70-536 | Keine Kommentare »

Loading ...
02. Oktober 2009
Hi there
We now leave types behind and go to the input/output chapter. I have to say, writing along while learning takes more time then just reading, but i hope it pays out at the end my having more information stuck in my brain ;o)
Drive Enumerating
- Use DriveInfo.GetDrives to get a List of Drives connected to the system
- You get a Collection over which you can loop
- Available Information: AvailableFreeSpace, DriveFormat, DriveType, IsReady, Name, RootDirectory,TotalFreeSpace, TotalSize, VolumeLabel
Files and Folders
- You can browse a folder by using an instance of DirectoyInfo and call .GetFiles or .GetDirectories
- You can create a directory by using an instance of DirectoryInfo and call .Create
- You can check if a directory Exists by DirectoryInfo.Exists
- Static File Operations: File.Create, File.CreateText, File.Copy, File.Move, File.Delete
- Alternative: Use an instance of FileInfo and call .Create, .CreateText, .CopyTo, .MoveTo, .Delete
Filesystem Monitoring
- Use System.IO.FileSystemWatcher (responds to updated, new and renamed files etc)
- FSW works Eventbased (Changed-Event, Create-Event, Delete-Event, Rename-Event etc.) and provides FileSystemEventArgs (except Rename, this provides RenamedEventArgs
- You can configure the Watcher with:
- Filter (Filename, you can use wildcards)
- NotifyFilter (Defines, what changes causing a notification (One or more): Filename, Size, LastAccess etc)
- Path (Folder to be monitored)
Tags: Exam 70-536, MCTS
Veröffentlicht in Allgemein, MCTS Examen 70-536 | Keine Kommentare »

Loading ...
30. September 2009
Hello everyone!
Today I learn about Type-Conversion and will share my notes with you. Have fun !
Lies den Rest des Artikels »
Tags: MCTS Exam 70-536
Veröffentlicht in Allgemein, MCTS Examen 70-536 | Keine Kommentare »

Loading ...
26. September 2009
Hello everyone,
a new day, a new learning experience. Today I work on the “Classes” chapter of my exam-preperation and will share the most interesting parts with you.
Inheritance
- Inheritance and Interfaces provide a way to improve a systems consistency
- via Inheritance you can create new classes from existing once
- With inheritance there comes the possibility to use derived classes interchangeably. That is calles polymorphism. You can for example pass an object of type specialobject (Inheriting of object) to a method which excepts an object.
Interfaces
- Interfaces are contract defining required members the new class must provide. For example the IComparable Interface defines a member method called CompareTo. Every class that implements IComparable must implement this Method.
- Commonly used Interfaces: IComparable, IFormattable, IEuatable, ICloneable, IConvertible, IDisposable
- Example Interface:
public interface IMyInterface
{
bool DoSomething();
string Message {get; set; }
int MyNumber {get;set;}
}
- “Extract Interface” is a build in Refactoring-Method of Visual Studio
Partial Classes
- A Class-Definintion can be split into different .cs files. This must be declared by using “partial” keyword in class definition (ex. public partial class}
Generics
- With Generics you can define a type and leav some details unspecified. You dont have to specify the type of certain parameters or members, instead you can define them, when using the new type
- Generics will be a bigger part of the exam
- In System.Collections.Generic you can find some Generics like Dictionary, Queue, SortedDictionary or SortedList.
- Advantages: Reduced run-time-errors (More typesafe) and improve performance (avoids boxing and unboxing)
- Example of Definition:
class MyGeneric
{
public T t;
public U u;
public MyGeneric(T _t, U _u)
{
t = _t;
u = _u;
}
}
- Important: Code needs to compile for every possible usage !
- Comsuming Example:
var test = new MyGeneric("hallo",12);
- Constraints for the Types used (T and U in the example above) can be defined.
class MyGeneric where T : IDisposable
- You can use Interfaces, Baseclasses,Constructors and Reference of value types as constraints
Events
- object (Event senders) can trigger events when an action takes place (User clicks button, method completed etc.)
- Event Receivers can handle these events when they occure
- A Delegate is a reference (pointer) to a method that itself has no code.
- The Delegates signature must match the signature of the handling method
- Things to do, to create a custom event:
- Create Delegate: public delegate void MyEventHandler(object sender, EventArgs e);
- Create event: public event MyEventHandler MyEvent;
- Fire Event
if (MyEvent != null)
{
// Invoke Delegate
MyEvent(this, new EventArgs());
}
- You can create your own EventArgs. Just create a new Class, that inherits from EventArgs.
Attributes
- Attributes describe Methods or Properties. You can get this information by reflection.
- Commonly used attributes for: Security Privileges, capability (ex.Serialization), description (title, copyright…)
- Attribute Types derive from System.Attribute
- Example – AssemblyAttributes in AssemblyInfo.cs : [assembly: AssemblyTitle("title")]
- Declaring capabilities:
[Serializable]
class MyClass
{
}
Without this Attribute, a class is not serializable.
- Declaring Security Requirements
[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, Read=@"C:\settings.ini")]
namespace MyNamespace
{
...
}
Type Forwarding
- Move a type from one assembly to another without needing recompile
- TypeForwardedTo – Attribute
- Example:
using System.Runtime.CompilerServices;
[assembly:TypeForwardedTo(typeof(TargetLib.MyType))]
- Works only for components referenced by existing applications
- To use Forwarding, do the following:
- Add TypeForwardedTo attribute to source assembly
- Cut Typedefinition from source and paste to destination
- Re-Compile both.
What have I learned ?
I havent used Attributes very often, so it was a good brush-up, and the Type-Forwarding Part was new for me, so I learned something today – Hurray !
)
Next Topic will be “Type Conversion” .. .stay tuned !
Tags: Classes, Exam 70-536, MCPD
Veröffentlicht in Allgemein, MCTS Examen 70-536 | Keine Kommentare »

Loading ...
21. September 2009
Hello everyone !
Hallo zusammen,
ein neuer Anlauf in Richtung Examen und die Entscheidung, die Blogsprache auf Englisch umzustellen, um schlichtweg mehr Leser anzusprechen. Ich hoffe, es stört nicht zu sehr
)
During todays power-cut (don’t know what happened, just no electricity for half an hour) I decided to continue my journey toward Microsoft exam 70-735, the first step to become MCPD.
I will post a summary of any chapter I work through, therefore its not exactly for beginners, more like a little learning help for me and hopefully other people reading it. By the way, my language of choice is C#, so this is what you will read about.
Lies den Rest des Artikels »
Tags: 70-536, Certification, MCPD, MCTS, Reference Types, Zertifizierung
Veröffentlicht in Allgemein, MCTS Examen 70-536 | Keine Kommentare »

Loading ...
20. Mai 2009
Guten abend,
Hab gerade mal meine Quellen gechecked, und bin direkt bei Microsoft fündig geworden.
Ab sofort kann man sich dort die Professional und die Team Suite, sowie den TFS in der 2010 Beta 1 Downloaden, außerdem die Beta 1 des .NET Framework 4.0.
Aber bitte erst downloaden, wenn ich selbst fertig bin ;o)
Ciao
Sascha
Achso, der Link ;o) http://msdn.microsoft.com/de-de/vstudio/dd582936(en-us).aspx
Tags: .Net 4.0, Beta, Beta 1, Visual Studio 2010
Veröffentlicht in .NET Future, Allgemein, News | Keine Kommentare »

Loading ...
15. Mai 2009
Guten Morgen,
nach der CTP folgt nun auch endlich die erste Beta von Visual Studio 2010. Subscriber können ab dem18.05. und alle anderen ab dem 20.05.2009 nun endlich die neue Version austesten.
So steht es zumindest auf dem Blog von Jihad Dannawi von Microsoft Australia. Mehr dazu nach erscheinen an dieser Stelle
)
Ciao Sascha
Veröffentlicht in Allgemein | Keine Kommentare »

Loading ...
21. Februar 2009
Guten Tag,
der Winter beherrscht Berlin, und wie es scheint auch den Rest der Republik. Was gibts da besseres, als sich mit einer Tasse Kaffee und einem Stück Mandarinen-Käse-Kuchen vor den PC zu setzen, und die letzte Woche revue passieren zu lassen.
Schönes Restwochenende
Sascha Baumann
Lies den Rest des Artikels »
Veröffentlicht in Allgemein, Links zum Wochenende, MVC Framework, News | Keine Kommentare »