Skip to main content

Posts

Showing posts with the label C#

Stack overflow is built using ASP.NET, C#, SQL Server, Windows, IIS...

Irrespective of what technology we work with how many times have we landed on Stack Overflow / Stack Exchange website on a daily basis? If we ask this to any developer the answer would mostly be MANY times in a day :) Site was launched in 2008 and is built using Windows, SQL Server, IIS, and ASP.NET along with HAProxy, Redis, and ElasticSearch, all served via Fastly CDN. Fun Facts: 1.3 Billion page views per month They transfer ~55 TB data per month 4 SQL Servers (organized as 2 clusters) Stack Overflow serves 528 Million queries per day (Peak 11000 queries per second) Stack Exchange, Careers, meta serves 496 million queries per day (Peak 12800 queries per second) Over 360 databases with the same schema, which changes frequently They made use of Microsoft Bizspark program before getting graduated All their production traffic is served using physical servers &  Cloud services are being used only for storing encrypted offsite backups (Glacier) and for DNS (Route53...

How to convert Roman numerals to Integer in C#

I was looking up the web all day but couldn't find any C# code for converting Roman letters or numerals to Integer value. The best thing i came across was this code by andyb  but the problem was it has been written in PHP which I had no clue :) So I had just taken the logic of AndyB and converted it into C# for anybody who cares for it. Add this Namespace: using System.Collections.Generic; Solution: Dictionary RomanNumbers =   new Dictionary (); RomanNumbers.Add("M", 1000); RomanNumbers.Add("CM", 900); RomanNumbers.Add("D", 500); RomanNumbers.Add("CD", 400); RomanNumbers.Add("C", 100); RomanNumbers.Add("XC", 90); RomanNumbers.Add("L", 50); RomanNumbers.Add("XL", 40); RomanNumbers.Add("X", 10); RomanNumbers.Add("IX", 9); RomanNumbers.Add("V", 5); RomanNumbers.Add("IV", 4); RomanNumbers.Add("I", 1); string strRomanValue = "M...

Swapping two integer values in C# [Interview Question]

Offlate, many of my friends where talking about this problem. It seems they ask this question frequently in Microsoft Interviews :) I remember asking this question to freshers in 2005! Just thought I would refresh my knowledge also on this :) So here are few samples which I tried for your reference. Method 1: Using intermediate temp variable int intNumOne = 1, intNumTwo = 2; int intTempVariable; //Swapping of numbers starts here intTempVariable = intNumOne; intNumOne = intNumTwo; intNumTwo = intTempVariable; Response.Write("Value of First Variable :: " + intNumOne.ToString() + "<br>"); Response.Write("Value of Second Variable :: " + intNumTwo.ToString() + "<br>"); Method 2: Without using Temp Variable and by using 8th standard Mathematics :) int intNumOne = 11, intNumTwo = 22; //Swapping of numbers starts here intNumOne = intNumOne + intNumTwo; intNumTwo = intNumOne - intNumTwo; intNumOne = intNumOne - intNumTwo; Response.Write(...