Extension Methods in C#

Extension Methods

There are some function that can be done on a string like String.Split(‘ ‘) ;

To add a new method like that we can go for using a Extension method.

In the following example I have added a new function test.getLength_Ext() to a string.

To do it

1) Create an accessible class with an accessible method

2) Both must be static If not it does not make any difference from creating a class.

3) The parameter(first) must be this followed by the type it must extend. In this case it Extends a string so I use test.getLength_Ext(this String)

public static class a

public static int getLength_Ext(this string str)
return str.Length;
class Program
static void Main(string[] args)
string test = “ABCDE”;

Hope you Understood . 🙂


Use of Global in C#

Definition From MSDN

The global contextual keyword, when it comes before the :: operator, refers to the global namespace, which is the default namespace for any C# program and is otherwise unnamed.


static void Main(string[] args)

// Define a Console integer to create a conflict

const int Console = 1;

// Console.WriteLine(“Test”); will not work as Console is a integer in the scope

// global in the following line says it has to refer to the Global namespace and not the current namespace.

Hope You Understood 🙂 .

Difference Between Struct and Classes in C#

The main difference between class and Struct

Class – Reference type .

Which means only a reference to a location is stored.

Struct – Value type.

Which means the value is stored.

Now lets create a class and struct a simple one that looks like.

// A class song

class Song
public string name;


// A struct songs

struct Songs

public string name;

// A console Application to demonstrate
class Program
static void Main(string[] args)
// reference type  – Two classes are created s , s1 
Song s = new Song();
Song s1 = new Song();

// A value is assigned to s 

s.name = “All Rise”;

// s –> s1 which means the reference to the value at a memory location is assigned to s1 

s1 = s;
Console.WriteLine(“Initial Value”);
Console.WriteLine(“from s1 :” + s1.name);
Console.WriteLine(“from s :” + s.name);

Console.WriteLine(“change to s1”);

//Any change to s1 is reflected to s also 

s1.name = “Beautiful”;
Console.WriteLine(“from s1 :”+s1.name);
Console.WriteLine(“from s :” + s.name);

// value type
Songs s3 = new Songs();
Songs s4 = new Songs();
s3.name = “All Rise”;
s4 = s3;
Console.WriteLine(“Initial Value”);
Console.WriteLine(“from s1 :” + s4.name);
Console.WriteLine(“from s :” + s3.name);


// Same thing is done in a struct but the values in s3 and s4will be different 


Console.WriteLine(“change to s1”);
s4.name = “Beautiful”;
Console.WriteLine(“from s1 :” + s4.name);
Console.WriteLine(“from s :” + s3.name);


Initial Value
from s1 :All Rise
from s :All Rise
change to s1
from s1 :Beautiful
from s :Beautiful

Initial Value
from s1 :All Rise
from s :All Rise
change to s1
from s1 :Beautiful
from s :All Rise

Hope you got the Difference. Ideally you can use a struct in case the size of the object is small. And you have a case as mentioned above.

How ever there are some things you need to know before using a struct .

– cannot have explicit parameterless constructor where as a class can.
-cannot have destructors.
-can’t inherit from another class.


Hope You got the Difference 🙂 .



Remove the numbers(Frame Rates) in windows phone emulator

Step 1: find the app.xaml.cs

step 2: find the following lines of code

// Show graphics profiling information while debugging.
if (System.Diagnostics.Debugger.IsAttached)
    // Display the current frame rate counters.
    Application.Current.Host.Settings.EnableFrameRateCounter = true;

    // other code…

Step 3: In the above code change to the frame rate counter to false you are done.

hope your problem is solved.

Creating a complete Windows Phone 8 APP online !! Really ?? – windows phone app studio

So you have a youtube channel or a blog reach more customers by making your presence in the store .

I started to explorer this as I got introduced to this through the DVLUP program by Nokia . If you are not in the program Explore by creating an account here www.dvlup.com/hariharaa/invite .

The place to go is apps.windowsstore.com ( aka windows phone app studio) . It is a cool online tool that will help you to create a complete app from A-Z .

What you need are

1) A computer 😛

2) Dev center account if you are a students visit your dreamspark  or bing for dev center (developer.windowsstore.com)

3) A good browser 😉

4) A online photo Editing tool or photoshop if you have one. ( I would go with pixlr.com/editor/‎) which is my fav online photoshop tool.This is to create logos and other images when you need them.

So when you have everthing lets get started.

We will see how to create a App for a youtube channel .

Step 1: Register with apps.windowsstore.com


Step 2:

Give the name for your app and other details as in the image


Step 3:

Adding pages and content

Step 4:

Editing Content

Customize Content


Add a media content from youtube . A media channel or search result of a query .


Adding a Video Source

Step 5:

The next step id using your creativity use it well to change your back ground colour and stuff .

Step 6:

Hit the next steps once completed and once the app is generated , you can do the following

1) download the package to upload to the store .

2) or get the source to modify .

I did it the easy way downloaded the package .xap and uploaded it to the store .

Hope you enjoyed creating the app.



Perceptual Computing a.k.a NUIs : My Love ;)

I Love Working on Natural user Interfaces .My love towards this area started when I was awarded a Microsoft Kinect  for being one amoung the top performers in the Microsoft’s Program MSP .


And before that I created my first application with the touchless SDK from CODEPLEX . I got lots and lots of positive reviews and I started sharing my Experiences on the same with my classmates , facebook friends and a few members of a developer commmunity.

You can view a video of my first applcation in the following Link : http://www.youtube.com/watch?v=8zEEZthFqnc and the working in http://www.youtube.com/watch?v=bogYCtnF5vA

Then I came across the Intel perceptual SDK which was fascinating . I took my first step . I thought of participating in the Intel Perceptual computing Challenge . And proposed an idea to convert the same Idea into something that can be used in a real world scenario like an Industry . After a few shots of scotch and my friends Android in hand I got an idea to provide authentication based on gestures.


And Here It is an   http://www.youtube.com/watch?v=yljzhOkM0jA  .

An Idea put into reality nothing can make anyone more happy.

Just Love what you do . And Do what you love .

Many asked me on how to create these systems . I will blog on how to create a basic application Soon .Stay Tuned .

Hope You enjoyed Reading. 🙂

Literal And Label Control

Difference Between Literal and Label in ASP

The mail difference is the way how the tags are rendered

<asp:Label….Text=”Hello World” ..> ==> <span >Hello World</span>

<asp:Literal…Text=”Hello World” ..> ==> Hello World

The next difference is that the labels can be associated for a certain control in the web forms.
On the other hand literals can be used to add plain English text or Html to the Document.

Hope you got the difference 🙂