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

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

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