Hi bhushan98,
I just checked the sample which is provided in the article you are reffering. And it is working completely fine.
If you are copying the code, then it may be possibe that the code is changed mistakenly while pasting.
So, to get rid of these type of issue you can simply download the provided sample with just one click.
Glad to assist!