Quantcast
Channel: C# – manski's blog
Browsing all 23 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

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 Article



C++ 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 Article

Image may be NSFW.
Clik here to view.

Microsoft 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 Article

Creating 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 Article

IDisposable, 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 Article


Image may be NSFW.
Clik here to view.

P/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 Article

Image may be NSFW.
Clik here to view.

Rectangle 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 Article


C# 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 Article

C++/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 Article

WCF: 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 Article

Bug 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 Article


Calculate 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 Article

Image may be NSFW.
Clik here to view.

Accessing 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 Article


Image may be NSFW.
Clik here to view.

Native 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 Article

P/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 Article


Mutexes 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 Article

Docker, .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 Article

Breaking .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
Browsing all 23 articles
Browse latest View live




Latest Images