Evaluate an mathematical expression

    public class MathEvaluator{ public static void Run() { Eval(“(1+2)”); Eval(“5*4/2”); Eval(“((3+5)-6)”); } public static void Eval(string input) { var ans = Evaluate(input); Console.WriteLine(input + ” = ” + ans); } public static double Evaluate(String input) { String expr = input.Substring(0,1) == “(” ? input : “(” + input + “)”; Stack<String> ops = new Stack<String>();…

    Read More

      Using HTTP Methods for RESTful Services

      The HTTP verbs comprise a major portion of our “uniform interface” constraint and provide us the action counterpart to the noun-based resource. The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations, respectively. There are…

      Read More

        To PUT or POST?

        Create, Update and HTTP Idempotence For developers building REST-based APIs, there is a great deal of misinformation and some understandable confusion about when to use HTTP PUT and when to use HTTP POST. Some say, POST should be used to create a resource, and PUT to modify one. Others that PUT should be used to…

        Read More

          Setup FileZilla Server Passive Ports on Windows Server 2012

          I prefer to use FileZilla FTP Server above the traditional IIS FTP module. FileZilla comes with a lite and lean GUI, great logging tools, connection (speed)limits and more. If you do not know FileZilla Server or the Filezilla Client I strongly encourage you to try them out at https://filezilla-project.org/ Setting up the FileZilla Server is…

          Read More

            C# Tutorial for log4net

            Here’s a short tutorial on how to use log4net in C# 1. Get log4net from the apache website or use NuGet to include in your project it   2. Add the Appender section to your app.config. The following code uses a file for the logging: <configuration> <configSections> <section name=”log4net” type=”log4net.Config.Log4NetConfigurationSectionHandler,Log4net”/> </configSections> <log4net> <root> <level value=”DEBUG”…

            Read More

              C# Code Snippet – Download Image from URL

              This .Net C# code snippet download image from URL. To use this function simply provide the URL of the image you like to download. This function read the image contents using URL and returns downloaded image as an image object. This function download image using web response stream. /// <summary>/// Function to download Image from…

              Read More

              Check Local IP Address

              This example shows how to detect whether a host name or IP address belongs to local computer. Get local computer name Get local computer host name using static method Dns.GetHostName. [C#] string localComputerName = Dns.GetHostName(); Get local IP address list Get list of computer IP addresses using static method Dns.GetHostAd­dresses. To get list of local…

              Read More

              Download Files from Web

              This example shows how to download files from any website to local disk. The simply way how to download file is to use WebClient class and its method DownloadFile. This method has two parameters, first is the url of the file you want to download and the second parameter is path to local disk to…

              Read More