Feeds:
Posts
Comments

Posts Tagged ‘c#’

Handy little discovery, I’m using it already!

I recently stumbled upon a little known operator in C#, that is pretty slick. It’s the “??” operator. Yeah, that’s right, it’s just 2 question marks. Unfortunately it’s nearly impossible to find anything in Google about it, since they don’t let you search for characters.

via The Little Known C# ?? Operator | SuperJason’s Personal Blog.

Google keywords:

question mark question mark
double question mark
.NET 2.0 coalesce
question mark operato

Advertisements

Read Full Post »

Excellent, now I can detect Visual Studio design time anywhere in my code. (Make sure to read the comments, they provide a valuable correction.)

I came across interesting issue with one of our controls. I needed a different behavior during design-time and run-time. I was sure that .NET Framework has a nice solution for me, but I found out this is not the case.There is a DesignMode property but according to several sources it doesn’t always work as expected. There seems to be more that one way to solve the issue. I decided to useSystem.Diagnostics.Process.GetCurrentProcess.ProcessNameand check if it equals string “devenv”. If it does, the instance is running inside Visual Studio, which means it’s design-time for our control. For my problem this simple solution worked as a charm.

via Detecting Design-time in C#.

Read Full Post »

Great primer on sending email in .NET, with code snippets.

Some 15 years later things have become quite a bit easier. Sending an e-mail is as straightforward as calling a few basic library functions and .NET of course includes a solid implementation.

via Using C# and .NET to send an e-mail through SMTP | Martijn’s C# Programming Blog.

Read Full Post »