Facebook Twitter


Microsoft Type Design Guildelines. From the CLR perspective, there are only two categories of types—reference types and value types—but for the purpose of a discussion about framework design, we divide types into more logical groups, each with its own specific design rules.

Microsoft Type Design Guildelines

Classes are the general case of reference types. They make up the bulk of types in the majority of frameworks. Classes owe their popularity to the rich set of object-oriented features they support and to their general applicability.


Tree<T>: Implementing a Non-Binary Tree in C# « Critical Development. Download the Source [This is the first article in a series of intelligent data structures, which is continued here with KeyedList.]

Tree<T>: Implementing a Non-Binary Tree in C# « Critical Development

I’ve always thought it was odd that the .NET Framework never shipped with a Tree or Tree<T> class in its collection namespaces. Most of the other classic data structures are there: List, Dictionary, Stack, Queue, and so on. Where then is Tree<T>? I have no idea, but finding myself in need of one, I decided to build one, and in doing so realized that it was a little trickier than I first imagined it would be. Asynchronous Programming - Easier Asynchronous Programming with the New Visual Studio Async CTP. Imagine what the world would be like if people worked the same way as computer programs: void ServeBreakfast(Customer diner){ var order = ObtainOrder(diner); var ingredients = ObtainIngredients(order); var recipe = ObtainRecipe(order); var meal = recipe.Prepare(ingredients); diner.Give(meal);} Each subroutine can, of course, be broken down further; preparing the meal might involve heating pans, cooking omelets and toasting bread.

Were humans to perform these sorts of tasks like typical computer programs, we’d carefully write down everything as sequences of hierarchical tasks in a checklist and obsessively ensure that each job was complete before embarking on the next. A subroutine-based approach seems reasonable—you can’t cook the eggs before you get the order—but in fact it both wastes time and makes the application appear unresponsive.

It wastes time because you want the bread to be toasting while the eggs are frying, not after the eggs are done and getting cold. Reflection Overview. Dynamic in C# 4.0: Introducing the ExpandoObject - C# Frequently Asked Questions. Well, where else can you use this new feature? What are the use cases? Where does dynamic dispatch work better than static typing? The quick answer is that whenever you see syntax like myobject.GetProperty("Address"), you have a use case for dynamic objects. First of all, the above syntax is difficult to read.

Second, you don’t have any IntelliSense support for the property name, and if the “Address” property doesn’t exist you get a run-time exception. Here’s a code example that I took from MSDN. XElement contactXML = new XElement("Contact", new XElement("Name", "Patrick Hines"), new XElement("Phone", "206-555-0144"), new XElement("Address", new XElement("Street1", "123 Main St"), new XElement("City", "Mercer Island"), new XElement("State", "WA"), new XElement("Postal", "68042") ) ); Impromptu-interface - ImpromptuInterface: Static interface to dynamic implementation (duck casting). That and more using the DLR. This Project has been moved to GitHub: C# 4.0 (.net & silverlight) framework to allow you to wrap any object (static or dynamic) with a static interface even though it didn't inherit from it.

impromptu-interface - ImpromptuInterface: Static interface to dynamic implementation (duck casting). That and more using the DLR.

It does this by emitting cached dynamic binding code inside a proxy. By expanding on the DLR plumbing used to implement this library, it has grown to support more general dynamic implementations. See Usage for full examples of all features. Other features include Really Late Binding, Inline Syntaxes, Currying, some dynamic extensions for FSharp, and unsealed Dynamic Objects including a fully dynamic MVVM ViewModel Quick Usage: using ImpromptuInterface; using ImpromptuInterface.Dynamic; public interface IMyInterface{ string Prop1 { get; } long Prop2 { get; } Guid Prop3 { get; } bool Meth1(int x); } //Anonymous Class var anon = new { Prop1 = "Test", Prop2 = 42L, Prop3 = Guid.NewGuid(), Meth1 = Return<bool>.Arguments<int>(it => it > 5) } var myInterface = anon.ActLike<IMyInterface>(); Get The Code Get The Samples.

Unusual uses of ExpandoObject in C# 4 : Reed Copsey, Jr. Posted by Reed on Friday, November 6, 2009 · 7 Comments Most of the examples for using ExpandoObject basically demonstrate a replacement for a Hashtable or Dictionary<string,object>, but with a “nicer” syntax.

Unusual uses of ExpandoObject in C# 4 : Reed Copsey, Jr.

For example, Alexandra Rusina blogged about using ExpandoObject, showing how you can use this to simplify access to XML documents. In general, this basically makes ExpandoObject a property bag – but the XML sample could have easily been written using a dictionary, if with a bit more verbose of a syntax. URL Routing in ASP.NET 4. By Scott Mitchell Introduction In the .NET Framework 3.5 SP1, Microsoft introduced ASP.NET Routing, which decouples the URL of a resource from the physical file on the web server.

URL Routing in ASP.NET 4

Using ASP.NET Routing Without ASP.NET MVC. By Scott Mitchell Introduction ASP.NET MVC is a Microsoft-supported framework for creating ASP.NET applications using a Model-View-Controller pattern.

Using ASP.NET Routing Without ASP.NET MVC

Chapter 9. Delegates, Events, and Lambda Expressions. Problem You have multiple objects that need to observe modifications to objects that implement IDictionary<K,V>.

Chapter 9. Delegates, Events, and Lambda Expressions

When an item is added or modified in the dictionary-based collection, each of these observer objects should be able to vote to allow or disallow the action. In order for an action to be allowed to complete, all observer objects must state if they are vetoing the action. If even one observer object votes to disallow the action, the action is prevented. Lambda Expressions (C# Programming Guide) A lambda expression is an anonymous function that you can use to create delegates or expression tree types.

Lambda Expressions (C# Programming Guide)

By using lambda expressions, you can write local functions that can be passed as arguments or returned as the value of function calls. Lambda expressions are particularly helpful for writing LINQ query expressions. To create a lambda expression, you specify input parameters (if any) on the left side of the lambda operator =>, and you put the expression or statement block on the other side.

For example, the lambda expression x => x * x specifies a parameter that’s named x and returns the value of x squared. You can assign this expression to a delegate type, as the following example shows: delegate int del(int i); static void Main(string[] args) { del myDelegate = x => x * x; int j = myDelegate(5); //j = 25 } Enumerable Methods (System.Linq) LINQ TO XML.

Getting Started Walking Through a Silverlight Application Take a tour of the XAML and Javascript generated by an application template that's installed with the Silverlight SDK. Organizing XAML Assets Learn how to organize XAML assets in Expression Design and Expression Blend to maximize developer efficiency. Hosting HTML Content. What is that IGrouping result returned from group by LINQ queries? I dont know how much you people use LINQ but for me it was like a blessing.

What is that IGrouping result returned from group by LINQ queries?

Since I figured out how helpful it is I never really looked back. But this post is not about obvious usefulness of LINQ, everyone should know that by now!!! I would like to clarify some exotic details on the results we get from group by queries with LINQ and explain a little bit more on that infamous IGrouping collection. Dynamic in C# 4.0: Introducing the ExpandoObject - C# Frequently Asked Questions.


Fabulous Adventures In Coding.