//Cloud notes from my desk -Maheshk

"Fortunate are those who take the first steps.” ― Paulo Coelho

Samples for Parallel Programming with the .NET Framework 4

While I was reading Jeffrey’s CLR via C# 3’rd edition, I happen to see a bunch of new classes added in .NET Framework 4.0 under the namespace System.Threading.Tasks – read @ MSDN Jeffrey talks about Tasks class in a length and also provided a pointer for Parallel prog in .NET 4.0.

Here is the link http://code.msdn.microsoft.com/ParExtSamples. I’ve downloaded the code, compiled with VS 2010. Very much impressed with the samples and comparison provided to demonstrate the performance and importance of Parallel computing code. Oh yeah, Sudoku.exe is also there as part of this download.

Supported version : .NET Framework 4.0

2010-03-29 Posted by | Uncategorized | Leave a comment

Microsoft Tech·Ed India 2010 TOP ARCHITECT – Contest

2010-03-15 Posted by | MS Events in India (Bangalore) | Leave a comment

What is .NET framework profile version ? ( VS 2010 )


– .NET Framework 4 Client Profile is a subset of features from the .NET Framework 4 & for other versions as well.
– Helps us to deploy fast in case of WPF & winforms
– Features not included in client profile shold target full .NET framework
– Performance improvement including mulitcore support, GC etc.
– Few ado.net, Wpf & wf improvements as well.

In nutshell, its a mini version, installs components that are the most relevant to desktop applications.

2010-03-12 Posted by | Uncategorized | Leave a comment

Simple way to confirm the .NET framework installation ?

1) Navigate to %SystemRoot%\System32 directory, look for MSCorEE.dll file. If Yes, then already installed

More about MSCorEE.dll : The process’s primary thread calls a method defined inside MSCorEE.dll. This method initializes the CLR, loads the EXE assembly, and then calls its entry point method (Main). At this point, the managed application is up and running.

2) Simple tool Which will tell you the framework version is installed – Download Framework detector

2010-03-12 Posted by | Uncategorized | Leave a comment

C# 4.0 new keyword and FAQ

1. Dynamic lookup


1.1) What is Dynamic lookup?

It’s a new static type, allows to write method, operator and indexer calls, property and field accesses etc gets resolved at runtime. Object is assumed at compile time to support any operation, and only at runtime will you get an error if it wasn’t so.


1.2) Any example for Dynamic lookup?

dynamic d = GetDynamicObject(10);


               dynamic value = 10;

               value.somedynamicoperation(); //resolved at runtime else exception 


1.3) Difference between var and dynamic keyword?

                varthe compiler knows the value and type at runtime

dynamic- resolve value assigned to it at run time. it is similar to object, but with dynamic dispatch: It can resolve properties, methods ,operators etc at runtime 

static void Main(string[] args)


string s = "this is a test string";


var v = "this is a test string";


dynamic d = "this is to test dynamic";

// it wont throw compilation error but will bomb during runtime

// Exception as "Microsoft.CSharp.RuntimeBinder.RuntimeBinderException" – ‘string’ does not contain a definition for ‘Something’

Console.WriteLine(d.Something());   // runtime error for missing method

Console.WriteLine(d.Length); // runtime error for missing prop



1.4) When to use dynamic & benefit ?

Useful when interacting with COM (which can have runtime-only properties), the DLR, or other dynamic systems, like javascript. Added to the CLR in order to support dynamic languages like Ruby and Python.


Read more about here : http://blogs.msdn.com/csharpfaq/archive/2010/01/25/what-is-the-difference-between-dynamic-and-object-keywords.aspx


2.Named & Optional Params

Both are different feature, will see first for Named parameter.


2.1 What is Named Parameter in C# 4.0?

Parameters are allowed to passed by naming rather following the order. We can pass the exact parameter leaving the default with explicit naming.

SomeMethod(s1: "UserProvided1", s3:"UserProvided3");// caller

private static void SomeMethod(string s1 = "Default1", string s2 = "Default2", string s3 = "Default3")



Console.WriteLine(s2);  //omitted by the caller but displays default value               









2.2 What are optional parameters?

It allows us to call a method with provided optional parameter..

       CalculateSum(10); //param 2,3,4 are optional, but param1 is mandate since there is no default value defined

       CalculateSum(10, 20); //param 3,4 are optional

       CalculateSum(10, 20, 30); //param 4 are optional           

      private static void CalculateSum(int a, int b=0, int c = 0, int d = 0)


            Console.WriteLine(a + b + c + d);



3. Features for COM interop

In order to have better interop performance at the COM level, few new features are added..such as Dynamic import, Compiling without PIAs,Omitting ref,Open issues etc to support better COM connectivity


4. Variance

It used to be that an IEnumerable<string> wasn’t an IEnumerable<object>. Now it is – C# embraces type safe “co-and contravariance” and common BCL types are updated to take advantage of that.

In C#, variance is supported in the following scenarios:

1.               Covariance in arrays (since C# 1.0)

2.               Covariance and contravariance in delegates, also known as “method group variance” (since C# 2.0)

3.               Variance for generic type parameters in interfaces and delegates (since C# 4.0)


Leave comments if you find good example for the Variance.


2010-03-12 Posted by | Uncategorized | Leave a comment

How to stop method overriding ? C# FAQ (tricky)


MSDN Ref : Read the last “topic-Consider sealing members that you override”

You can use this approach to ensure that derived classes do not modify or bypass behavior required for the current class and all derived classes.

Read from here : http://msdn.microsoft.com/en-us/library/ms229023(VS.80).aspx

2010-03-11 Posted by | Uncategorized | 1 Comment


%d bloggers like this: