How to use RailPNRAPI to get PNR Status?

Here I’m sharing the sample code on How to consume API provided by railpnrapi.com to query Indian Railway PNR status: Register yourself on http://www.railpnrapi.com/ and get/generate API Key & API Secret. using Newtonsoft.Json;using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Net;using System.Security.Cryptography;using System.Text; namespace RailPnrAPI_SampleCode{¬† ¬† class Program¬† ¬† {¬† ¬† ¬† ¬† static void Main(string[] args)¬† ¬† … Read more

Use of Coding Standards in Programming

If¬†you’re¬†working in a team and use Visual Studio for development then here are few¬†guideline tips on how you could improve the pace and maintain the uniformity among all your team champs. Even if¬†you’re¬†working alone, it will help you¬†to stay on a track rather moving on different track as you go further hence allow you to … Read more

A new guard page for stack cannot be created- ASP.NET MVC4 Error

An hour back I was working with ASP.NET and encountered with this pretty error. I kept wandering for about ten minutes what really has happened. My iisexpress.exe was automatically shut down and it didn’t work when I kept hitting CTRL+F5. How I solved it:Later i the process I came to know that I had the … Read more

“object does not contain a definition for get_Range” in Excel C#

Error: ‘object’ does not contain a definition for ‘get_Range’ Line of Code: Excel.Range¬†header¬†=¬†wks.get_Range(wks.Cells[1,¬†1],¬†wks.Cells[1,¬†10]); Solution: Cast the cells as “object” in get_Range() Excel.Range¬†header¬†=¬†wks.get_Range((object)wks.Cells[1,¬†1],(object)¬†wks.Cells[1,¬†10]); Thanks!

How to convert Visual FoxPro DBF file to Excel in C#

The very first thing as you go start doing this stuff, make sure you’ve downloaded and installed Visual FoxPro Driver on your host machine. Here the link for download: http://www.microsoft.com/en-us/download/confirmation.aspx?id=14839 Use OleDbConnection to get the records into DataTable and later export/write the DataTable to Excel. Here are the complete codes: using¬†System; using¬†System.Data; using¬†System.Data.OleDb; using¬†System.IO; using¬†Excel¬†=¬†Microsoft.Office.Interop.Excel; … Read more

How to handle negative TimeSpan value in C#?

I had problems with casting TimeSpan object to DateTime. Error occured: FormatException (“the input string was not in proper format”).Code I tried:DateTime.Parse(record.Field(“Hours”)); // raised errorHere record is a DataRow object and I’m using Linq to Objects to parse the Date.//Field actual value :”{-06:25:00}”How did I overcome?I used .Duration() method of TimeSpan object.DateTime.Parse(record.Field(“Hours”).Duration());¬†HTH ūüôā

What is API and How to use it?

what is an api

Have you ever used a library in C#? Yes, that’s an API. An Application Programming Interface is something that let’s you interact with something or with an interface. They are just a set of functions you can call. They have their documentation on¬†what they do,¬†how they behave, what input(s) they need to perform as intended. … Read more

What is toString(“X2”)?

“X2” here denotes the hexadecimal format specifier.¬†Standard numeric format strings are used to format common numeric types. A standard format string takes the form¬†Axx¬†where¬†A¬†is a single alphabetic character called the format specifier, and¬†xx¬†is an optional integer called the precision specifier. The format specifier must be one of the built-in format characters. The precision specifier ranges … Read more