Posts tagged ‘C#’

Simple but Elegant, Creating a class from String

Creating a class from a string might be crucial for some very dynamic projects. It’s a single line of code that I wanted to share but I think it has a lot of power.

Simply get the executing assembly and call the GetType method. If your assembly is one of the linked assembly or even a […]

Emulated Managed Windows Pipes with Standard Input and Output

Pipes are around since Unix, Linux and Windows 95. Pipes are a way of communication between two programs. It’s a virtual channel to the process. Normally it is a system function call in the kernel.dll.
A pipe is a one way channel that you can write or read. So to write and read basically we need […]

Reflection for Properties and Fields with DynamicMethod

Lastly I posted about the coolest exception while working with System.Reflection.Dynamicmethod class. I found the solution for my bug, and now it works like a charm. There are two classes for accessing properties or fields, one with the generic implementations and one with object implementation. Using the reflection with dynamicmethod reflection we can get 80% more […]

ImageLabel Control for ASP.NET (Potential CAPTCHA Control)

I posted an article to The Code Project for an image control. The basic idea for developing that is to write e-mail addresses as images using various formatting options on web applications.
Labels are generated as images instead of text, to have more privacy without any configurations and without HttpHandlers
ImageLabel is an ASP.NET web control […]

Uncommon Collection features : Indexers, Multiple Indexers with Params and yield

Collections are the most used elements in the programs. Indexers helps us to access the elements of a collection. Although you might not have implemented indexers, you have used indexers a lot. Whenever you have an array or a collection object you use indexers.
Implementing indexers is done by coding “this[TYPE]” property. The object implementing the indexer […]

XNA Game Studio Express (Beta) Now Available

I am just downloading it. Download it too. You also need to download Visual Studio C# Express as the documentation says. Also for audio you might need Directx SDK, So downloading all of them.

XNA Game Studio Express
Visual Studio C# Express
Directx SDK (August 2006)

Useful Links
XNA ReadmeXNA Team BlogXNA Forums

Nullable Types - Null-Coalescing Operator ?? in C# .NET 2.0

Nullable types are instances of Nullable structure. This Nullable structure is a generic struct type in base class library. It behaves like value type when it has a value which means that boxing or unboxing occurs. However when it does not have a value, it is null instead of the value types default value, and boxind […]

Reflection with Private Members

By using reflection we can call any function including the private and protected ones. This includes private static methods, constructor methods, normal methods. What we need to do is to get the method by the BindingFlags.Nonpublic flag and then we just use it like a reflected type.

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
 
namespace ReflectPrivateMembers
{
[…]

XML Class Generator for C# using XSD for deserialization

Let’s say we have an XML file and we want to deserialize that file to our implemented class. This is an easy task if the XML file is simple. However if it has more complex types, it can take a long time to implement the class without error. XSD comes with .Net framework SDK. I […]

The coolest exception I’ve ever get : FatalExecutionError

I get the coolest exception from .Net FatalExecutionError. What is cool for that exception is that it is assuming that itself might be wrong. “This error may be a bug in the CLR.” So I might not be the one who generated, I can just blame CLR for doing that

“The runtime has […]