Blog

posts tagged with visual studio

C# boxing with string concatenation and interpolation

4 Comments
By Fons Sonnemans, 10-jan-2020

C# boxing with String concatenation and interpolation

Boxing is evil and you should always try to avoid it. That is what I tell my students in my C# training. But what is boxing and how do you avoid it. Boxing is wrapping a value type (struct) inside a reference type (object or interface) variable.

using System;

namespace BoxingDemo {
    class Program {
        static void Main(string[] args) {
            int a = 5;
            object b = a;      // boxing
            IComparable c = a; // boxing
            int d = (int)b;    // unboxing, also evil (slow)
        }
    }
}

Boxing is evil because it is “slow”. It creates a reference type (the boxed value) which the garbage collector has to clean up (which is also “slow”). I will first explain how you can detect boxing and then how to avoid it when using string concatenation and interpolation.

READ MORE

Fons Sonnemans 2019 Development Tools List

0 Comments
By Fons Sonnemans, 20-nov-2019

Many years ago Scott Hanselman wrote the famous Scott Hanselman Ultimate Tools List post. Now it is time to write my own list because there are new tools. I'm an App developer more than a Web developer so I use different tools. I write mainly XAML (UWP and WPF) apps and only occasionally an ASP.NET website. My code is written in C#. I create them because it is fun to do and it helps me to train my own skills. I use this experience for my trainings (C#, XAML, ASP.NET and SQL). I write my own training material so I need the experience. I have about 40 Windows apps in the Store, some are very popular. The apps have almost 5 million downloads and daily thousands of players. Most of my apps are free but there are Ads in it to generate some revenue.

READ MORE

Using C# 8.0 in Core 2.x, .NET Framework and UWP projects

4 Comments
By Fons Sonnemans, 09-jul-2019

With Visual Studio 2019 Preview (currently version 16.2.0 Preview 3.0) you can use C# 8.0 in  .NET Core 3.0 projects. You only have to set the Language version to C# 8.0 (beta) in the Advanced Build Settings. Make sure you do this for 'All configurations' and 'Any CPU', see screenshot below.

Build Settings

This setting will add a LangVersion property to your .csproj file (line 6).

Core 3.0 project file

READ MORE

PEAK-IT Summer DevNight 2008

0 Comments
By Fons Sonnemans, 04-jul-2008

On Juny 3, I did a Visual Studio 2008 presentation on the PEAK-IT Summer DevNight 2008 at the Fulcotheater in IJsselstein.

You can download the slide deck here.

I had a good time presenting this sessions. I hope it was a useful for you as well.

READ MORE

ConvertSelectedTextToAssociatedLabel Macro

0 Comments
By Fons Sonnemans, 09-okt-2007

I have created a new Visual Studio 2005 Macro which can be used to convert a literal text to an asp:Label that is associated to the next control. You first have to select the text and then Run the ConvertSelectedTextToAssociatedLabel Macro. In the example below the text Age: is selected.

The result is an asp:Label with the correct Text and AssociatedControlID attributes.

Download Zipfile

READ MORE

My Code Snippets

0 Comments
By Fons Sonnemans, 02-okt-2007

I use Visual Studio 2005 Code Snippets a lot. Especially during trainings. I have created some snippets myself which I want to share. Download this zipfile and extract it in the "My Documents\Visual Studio 2005\Code Snippets\Visual C#\My Code Snippets" folder.

READ MORE

My First XNA Game

0 Comments
By Fons Sonnemans, 27-mei-2007

I finally found some time to play with XNA. I learned a lot from Rob Miles at TechEd 2006. He has some great samples on his website. Rob will also be presenting about this subject on the DevDays 2007 in the Netherlands. Fun is guaranteed.

My first game is a remake of a game I build 20 years ago on my Commodore 64. You must move around a bouncing ball using your joystick. The ball may not collide with the flying birds. It took me only a few hours to build and it was great fun.

XNA - Drawing Text in XNA

READ MORE

New VS2005 Macros

0 Comments
By Fons Sonnemans, 18-nov-2005

Three years ago I have written some useful Visual Studio 2003 macros: SortCode and CreateProperty. With the introduction of VS2005 it was time to upgrade them.

The new SortCode macro also supports VB.NET 2005. Totally new is the EncapsulateAllNonPrivateFields macro. It creates properties get/set for all non private (public, protected, internal) fields. By using the CodeDom I managed to supports VB.NET and C#.

Example

After running the marco the 3 fields are private and there are 3 extra properties.

READ MORE

SDE Slides

0 Comments
By Fons Sonnemans, 20-sep-2005

The slides from my presentation 'NDoc Integratie in Visual Studio 2003 & 2005' can now be downloaded.

READ MORE

PDC05 Keynote

0 Comments
By Fons Sonnemans, 13-sep-2005

I have just watched the live PDC05 Keynote Webcast. I'm very impressed. Great demo's showing LINQ, Indigo, Atlas and Avalon. The problem for Microsoft will be to get us 'the developers' to use these new technologies as soon as possible. I'm afraid it is all to much for a 'normal' developer too cope with.

READ MORE

All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.