Posts

Showing posts from February, 2012

Annotation in C# for mapping JsonProperty to a variable

If for some reason you are .NET Framework 2.0 and using Newtonsoft.Json libray than this is gonna be very useful. You have a case where your Json property contains a '-' sign, than obviously you can't have a C# variable to map the same as variable naming scheme does not allow - signs. I recently faced a similar problem and spent hours googling to figure out how to do it in .net 2.0 but all the efforts were in vain. Than after a lot of hit and trial and reading source files I hit this annotation JsonProperty("my-name") and hurray it worked. Just to provide a small example usage: JSON: {"my-name" : "Biplav"} C# snippet: public class Name {    private String m_my_name;    [JsonProperty("my-name")]    public String my_name    {       get { return m_my_name;}       set  { m_my_name = value;}   }

How function overriding is different in C# from Java?

If you are moving from Java to C#, than this is one thing which you would find very funny. Suppose you wrote the following code: class a {    public void display()     {      Console.WriteLine("A");    } } class b:a {    new public void display()    {     Console.WriteLine("B");    }  } And did something like: A a = new B(); a.display(); B b = new B(); b.display(); The output would be: A B Although we expect here that as we have overriden display in B, so the display of B must be called. But this assumption is incorrect as we have reserved reference for A, so the C# compiler won't know that B can override display function. Hence we need to tell the compiler that there is a possibility that display can be overriden in derived classes and please check for it. To do so we would have to define the baseclass function which can be overriden as virtual and than use override keyword in all the derived classes. So tha

Facebook Hidden Messages Folder

Image
I did'nt notice this till now, and there are chances that you might not have too. There is a hidden(not exactly) messages folder on facebook where all the messages from you non-friends go to. To reach this folder, first click on messages on the left-hand bar and than click on the others just below it. You might discover lots of messages from various contact since you have been on facebook. I was suprised to see that there were no. of messages/events from the pages i follow, which I would have loved to read and attend but now its too late :(. On doing a little more research about this simple feature on Facebook, this is what i found on there blog The Social Inbox It seems wrong that an email message from your best friend gets sandwiched between a bill and a bank statement. It's not that those other messages aren't important, but one of them is more meaningful. With new Messages, your Inbox will only contain messages from your friends and their friends. All other m

junglee.com Review

Image
Many of you would have seen junglee.com and would be wondering what so special about it? I was doing the same, till i had this unofficial interview with Junglee.com (JC). Read along: Me: What is junglee.com ? JC: I would like to describe ourself in one word, Product Search Engine, rather it became three. Me: I can search on Google and find my product. Whats so special? JC: Okie we have a product comparator. We would devoid you of the pain of going to various websites and comparing the prices and reading the reviews before you buy anything! Me: Ahh!Now you are speaking sense. So you are advanced version of yellow pages. So, do i get the cheapest products over here? JC: Yes and No. Me: What do you mean "yes and no"? JC: Technically, it lists prices from most of the online and offline stores in India. So you can get the cheapest price. But it does not have the prices from flipkart.com and infibeam.com .  Me: What, I usually buy all my books from flipka