C#

FacebookTwitter
http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/ An interesting new feature in C# 3.0 is that of automatic properties on objects – this allows us to define a get/set property and the creation of the underlying field is taken care off for us. We can therefore create a class like this: public class Foo { public string Bar { get ; set ; } }

Public fields vs automatic properties

Introduced in C# 2.0, the null coalescing operator (??) allows one to program in a concise, declarative fashion when performing null checks. This was important in 2005 as it made it easier to utilize another important feature: nullable types.

Why You Should Use the Null Coalescing Operator

http://www.kodefuguru.com/post/2009/12/20/Why-You-Should-Use-the-Null-Coalescing-Operator.aspx
As you might have heard by now, C# 4.0 (or is it just 4?…) comes with a new keyword: dynamic . This means that you could do something like the following: Simply put, ExpandoObject is a class that allows you to add and remove members at runtime. This allows us to call methods that are resolved at runtime.

Dynamic objects and ReSharper

http://devlicio.us/blogs/hadi_hariri/archive/2009/11/24/dynamic-objects-and-resharper.aspx

FileSystemWatcher and IOException Class

This article has been excerpted from book "The Complete Visual C# Programmer's Guide" from the Authors of C# Corner. Another very useful class, FileSystemWatcher, acts as a watchdog for file system changes and raises an event when a change occurs. You must specify a directory to be monitored. The class can monitor changes to subdirectories and files within the specified directory. http://www.c-sharpcorner.com/uploadfile/puranindia/filesystemwatcher-in-C-Sharp/

Create a Relative path code snippet

http://weblogs.asp.net/pwelter34/archive/2006/02/08/create-a-relative-path-code-snippet.aspx public class PathUtil /// <summary> /// Creates a relative path from one file

MathML Visualizer in C# on Windows 7

http://community.bartdesmet.net/blogs/bart/archive/2009/02/11/mathml-visualizer-in-c-on-windows-7.aspx Wednesday, February 11, 2009 10:37 AM bart Lately I’ve been playing quite a bit with mathematical representation formats like OMML (Office’s markup language for math) and MathML (the nice thing about standards is …, well you know). Both have their pros and cons, but let’s not dive into that for now. In today’s post, I’m showing you the new Windows 7 “Math Input Panel” and how you can retrieve its MathML data from the clipboard in a UI application. I’m actually using this technique to read MathML and feed it in to my interpreter that tries to turn it into execution.
http://www.codethinked.com/an-overview-of-system_collections_generic I recently put up a post on my blog about some of the new concurrent collections in .NET 4.0, and I noticed that a lot of people were being sent by Google to those posts who were only searching for System.Collections. I figured that maybe people could use a similar overview of the collections available to them in the System.Collections.Generic namespace, since it seems to me that no one uses anything other than List and Dictionary. So, in this post, I am going to take a look at a few of those collections, and explain exactly why you would want to use them.

An Overview Of System.Collections.Generic

Reflection on a method with an out parameter

Thursday, December 10, 2009 2:47 PM plblum As I code my commercial Dynamic Data libraries for ASP.NET 4 support, I’ve elected to deliver one assembly compiled under .net 3.5 SP 1 that also supports new features of ASP.NET 4. 3.5SP1 is the initial release of Dynamic Data. To interact with the new properties and methods in ASP.NET 4, I am using .net Reflection . I have long used .net reflection, so I didn’t think there were many more things to learn. http://weblogs.asp.net/peterblum/archive/2009/12/10/reflection-on-a-method-with-an-out-parameter.aspx
http://tirania.org/blog/archive/2009/Dec-20.html

C# String Interpolation

We have discussed in the past adding support to C# to support string interpolation. I have cooked a patch that allows C# developers to embed expressions inside strings, like this: var a = 'Hello {name} how are you?'
http://weblogs.asp.net/gunnarpeipman/archive/2009/08/15/displaying-custom-html-in-webbrowser-control.aspx 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. Problem When we look at methods and properties of WebBrowser control our common sense tells us that something like this should work (VB.NET users: delete “;” after this line):

Displaying custom HTML in WebBrowser control

String Formatting in C#

I couldn’t find a quick reference to .NET string formatting using the String.Format() function, so I created this one (which has also spawned this String Formatting FAQ ). When I started working with the .NET framework, one thing puzzled me. I couldn’t find sprintf(). sprintf() is the C function that takes an output buffer, a format string, and any number of arguments, and builds a string for you. For example: char szError[256]; sprintf(szError, “Error %d occurred.