C# für Java-Programmierer
Mir fällt gerade ein, dass ich doch noch einen Nachtrag nachreichen muss: Und zwar ist über die Weihnachtsferien (im Schweiße meines Angesichts so zu sagen) ein Artikel mit dem Titel “C# für...
View ArticleC++ and virtual methods (for C# or Java programmers)
Table of Contents [hide] 1 The C# Example 2 The C++ Problem 3 Example Visual Studio Solution Last friday I stumbled over a seroius shortcomming of C++ (compared to C# or Java) I’d like to share here...
View ArticleMicrosoft Epic Fail – Eine Odyssee
Manchmal nervt Programmieren einfach. Da hat man folgende Zeile in C++ (bääääh): PathOption test = mQ1Settings->WorldDir; Versucht man diese mit Visual C++ 2010 zu kompilieren, stürtzt der...
View ArticleCreating an Application class in Mono for Android
Android provides an Application class. Base class for those who need to maintain global application state. Here’s how to create such a class in Mono for Android: [Application] // <-- Attribute...
View ArticleIDisposable, Finalizer, and SuppressFinalize in C# and C++/CLI
The .NET framework features an interface called IDisposable. It basically exists to allow freeing unmanaged resources (think: C++ pointers). In most cases, you won’t need IDisposable when writing C#...
View ArticleP/Invoke Tutorial: Basics (Part 1)
P/Invoke is a way of calling C/C++ functions from a .NET program. It’s very easy to use. This article will cover the basics of using P/Invoke. Note: This tutorial will focus on Windows and thus use...
View Article.NET Performance: primitive type vs. struct
For a project I was wondering what’s the performance penalty of using a C# struct (containing only one field) over using a local variable directly; i.e.: int myVar; vs. struct MyStruct { int MyVar; }...
View ArticleRectangle Intersection Test (with C#)
For a software project I needed to check whether two rectangles intersect (or overlap). What made my problem complicated was that one of the rectangles could be rotated. While this problem seems to be...
View Article.NET – Array.Clear() vs. array[x] = 0 – Performance
So, yet another performance test for .NET. This time I was checking what’s the fastest way to clear an array (i.e. setting all array members to 0 or null). The two contesters are: array[x] = 0...
View ArticleC# and GC.KeepAlive()
Today, while browsing some C++/CLI code, I stumbled upon several calls to GC.KeepAlive(someObj). Immediately I thought memory leak – because I thought KeepAlive() would keep the object alive...
View ArticleC++/CLI Cheat Sheet
This article provides a quick comparison between C++/CLI and C#. It’s meant for those who know C# (and possibly C++) and will explain which C++/CLI language construct correspond with which in C#. (I...
View ArticleWCF: Real Easy
If you search for WCF tutorials, you’ll find a lot of elaborate examples that involve editing several files. This tutorial is (supposed to be) different. It uses the simple most approach I could find...
View ArticleBug of the day: Broken renaming in ReSharper
In my opinion, refactoring is the way to keep a software project clean. So, it’s good to have tools that support the refactoring process. ReSharper is such a tool. It provides refactoring capabilities...
View ArticleCalculate return value for sort by int
Most programming languages (such as C#, Java, …) allow you to sort lists. Most of them also allow you to specify a sorting function so that you can customize the sort order. These functions usually...
View ArticleAccessing Java Classes from Mono for Android via JNI
Mono for Android let’s you write Android applications in a .NET language (for example, C#). It comes with wrappers for almost the entire Android API so building “standard” apps is easy enough....
View ArticleNative libraries in MonoDroid library projects
Currently, MonoDroid (Mono for Android) doesn’t support native libraries (or any other Android resource type) in library projects (bug report). Fortunately, they support normal .NET assembly...
View ArticleP/Invoke Tutorial: Passing strings (Part 2)
In the previous tutorial we passed a single string to a native C/C++ function by using P/Invoke. This function was defined like this: // C++ void print_line(const char* str); // C#...
View ArticleMutexes in .NET
The Mutex class in .NET is a little bit tricky to use. Here’s an example how I got it to do what I want: /// <summary> /// A simple, cross application mutex. Use <see cref="Acquire"/> to...
View ArticleDocker, .NET Core and (NuGet) Dependencies
Recently, I wanted to try out the new .NET Core together with a Docker container. However, coming from programing .NET applications for the regular .NET Framework, there were some obstacles I...
View ArticleBreaking .NET’s Random class
Security is hard. In a current project I saw some code that created some access tokens based on a random number generator – .NET’s Random class. The code used an instance of Random stored in static...
View Article
More Pages to Explore .....