X

.NET

Optional arguments and named parameters in C#

C# 4.0 supports optional method arguments. Related to this is support for named parameters in function calls. For us it makes easier to use methods which have long argument list. It also introduces some new dangers which may lead us to messy and hard to understand code. In this code I will show how to use optional arguments and give some hints how to avoid messy code.

Developing Delicious applications

I am developing a little piece of software that interacts with Delicious through HTTP API. Using Delicious API puts you one responsibility – use their service carefully. Don’t flood it and don’t stress it some other way. In this posting I will show you how to get bookmarks from Delicious and how to use their service without stressing it pointlessly. (more…)

Displaying custom HTML in WebBrowser control

I am using WebBrowser control to show preview of automatically generated HTML. Users can select options and preview pane reflects those changes automatically. WebBrowser control has some problems that have been here for years already. Here is my example about how to show custom HTML in WebBrowser control.

Using memory mapped files with C#

.Net Framework 4.0 introduces memory mapped files. Memory mapped files are useful when you need to do in-memory data manipulation and your data structures are large. For large in-memory data the performance of memory mapped file is the best. It is much faster thanMemoryStream. And like files on hard disc, memory mapped files can be shared between different programs. MemoryMappedFile and other classes for memory mapped files can be found from System.IO.MemoryMappedFiles namespace.

Visual Studio 2010 and .Net Framework 4.0 downloads

Here is the list of all downloads available for Visual Studio 2010 and .NET Framework 4.0. Also learning and hosting resources are included.

Reading embedded files at runtime with C#

I have class library that contains some XML-files as embedded resources. Reading these files at runtime is very easy. It takes only couple of lines of code.

Using BigInteger with C#

My previous posting was about performance of Fibonacci numbers algorithms. In this posting I will introduce you some problems related to limits of our usual integers and introduce you new feature in .Net Framework 4.0 – big integers. Big integers are useful when solving different mathematical problems. Also they are used in cryptography.

How parallel LINQ works

.Net Framework 4.0 has parallel computing extensions for LINQ. Previously it was possible to download parallel extensions for LINQ separately from CodePlex. Of course, you can still use these extensions if you have older version that 4.0. I wrote a little, simple and pretty pointless example that illustrates how parallel queries work in .Net Framework 4.0.

Using Lazy<T> for lazy loading

.Net Framework 4.0 introduced a new class called Lazy. Lazy provides support for several common patterns of lazy initialization, including the ability to initialize value types and to use null values. It’s a powerful and very useful beast but underrated in practice. Here’s how to use it.

Writing rich logging solution

Tests tell us if our software works as expected. But they tell us almost nothing about side effects of technical environment where system lives. We can face different problems when test users start testing system in their environment and we want to be ready to react fast to all problems. To get information about system’s work we need advanced logging.