Getting Top N rows from DataTable.

public DataTable getTop(DataTable dt, int n)
    DataTable outputTable = dt.Clone();
    for (int i = 0; i < n; i++)
    return outputTable;


How to create your own custom code snippets in Visual Studio.

Snippet Symbol that appears in Intellisense window.

for e.g. in C# we have snippet like below:

ctor – for default class constructor

for – for default for loop snippet

prop – to create property

etc. So what you do is just type these words and double tap on TAB key and code get generated there just like that.

Install the above plugin Restart your VisualStudio. Now follow below steps:

Go to Menu File-> New –> File.. option

Updating Dictionary elements while iterating.

As we know we can’t update any collection element if we are iterating them using foreach loop.
For example, we could iterate Dictionary using KeyValuePair in foreach loop but we can’t modify them. But what if we want to iterate the entire dictionary and at the same time also we have a need to modify the Dictionary Elements.

Read more:

By Sriramjithendra Posted in C#.NET