diff --git a/test/csharp/CSharpClient.cs b/test/csharp/CSharpClient.cs
index 2cb6a83..d4d626f 100644
--- a/test/csharp/CSharpClient.cs
+++ b/test/csharp/CSharpClient.cs
@@ -1,68 +1,68 @@
-using System;
-using Thrift;
-using Thrift.Protocol;
-using Thrift.Server;
-using Thrift.Transport;
-
-
-namespace CSharpTutorial
-{
-    public class CSharpClient
-    {
-        public static void Main()
-        {
-            try
-            {
-                TTransport transport = new TSocket("localhost", 9090);
-                TProtocol protocol = new TBinaryProtocol(transport);
-                Calculator.Client client = new Calculator.Client(protocol);
-
-                transport.Open();
-
-                client.ping();
-                Console.WriteLine("ping()");
-
-                int sum = client.add(1, 1);
-                Console.WriteLine("1+1={0}", sum);
-
-                Work work = new Work();
-
-                work.op = Operation.DIVIDE;
-                work.num1 = 1;
-                work.num2 = 0;
-                try
-                {
-                    int quotient = client.calculate(1, work);
-                    Console.WriteLine("Whoa we can divide by 0");
-                }
-                catch (InvalidOperation io)
-                {
-                    Console.WriteLine("Invalid operation: " + io.why);
-                }
-
-                work.op = Operation.SUBTRACT;
-                work.num1 = 15;
-                work.num2 = 10;
-                try
-                {
-                    int diff = client.calculate(1, work);
-                    Console.WriteLine("15-10={0}", diff);
-                }
-                catch (InvalidOperation io)
-                {
-                    Console.WriteLine("Invalid operation: " + io.why);
-                }
-
-                SharedStruct log = client.getStruct(1);
-                Console.WriteLine("Check log: {0}", log.value);
-
-                transport.Close();
-            }
-            catch (TApplicationException x)
-            {
-                Console.WriteLine(x.StackTrace);
-            }
-
-        }
-    }
-}
\ No newline at end of file
+using System;
+using Thrift;
+using Thrift.Protocol;
+using Thrift.Server;
+using Thrift.Transport;
+
+
+namespace CSharpTutorial
+{
+    public class CSharpClient
+    {
+        public static void Main()
+        {
+            try
+            {
+                TTransport transport = new TSocket("localhost", 9090);
+                TProtocol protocol = new TBinaryProtocol(transport);
+                Calculator.Client client = new Calculator.Client(protocol);
+
+                transport.Open();
+
+                client.ping();
+                Console.WriteLine("ping()");
+
+                int sum = client.add(1, 1);
+                Console.WriteLine("1+1={0}", sum);
+
+                Work work = new Work();
+
+                work.op = Operation.DIVIDE;
+                work.num1 = 1;
+                work.num2 = 0;
+                try
+                {
+                    int quotient = client.calculate(1, work);
+                    Console.WriteLine("Whoa we can divide by 0");
+                }
+                catch (InvalidOperation io)
+                {
+                    Console.WriteLine("Invalid operation: " + io.why);
+                }
+
+                work.op = Operation.SUBTRACT;
+                work.num1 = 15;
+                work.num2 = 10;
+                try
+                {
+                    int diff = client.calculate(1, work);
+                    Console.WriteLine("15-10={0}", diff);
+                }
+                catch (InvalidOperation io)
+                {
+                    Console.WriteLine("Invalid operation: " + io.why);
+                }
+
+                SharedStruct log = client.getStruct(1);
+                Console.WriteLine("Check log: {0}", log.value);
+
+                transport.Close();
+            }
+            catch (TApplicationException x)
+            {
+                Console.WriteLine(x.StackTrace);
+            }
+
+        }
+    }
+}
diff --git a/test/csharp/CSharpServer.cs b/test/csharp/CSharpServer.cs
index 5eef03b..de82a49 100644
--- a/test/csharp/CSharpServer.cs
+++ b/test/csharp/CSharpServer.cs
@@ -1,110 +1,110 @@
-﻿using System;
-using System.Collections.Generic;
-using Thrift.Server;
-using Thrift.Transport;
-
-namespace CSharpTutorial
-{
-    public class CalculatorHandler : Calculator.Iface
-    {
-        Dictionary<int, SharedStruct> log;
-
-        public CalculatorHandler()
-        {
-            log = new Dictionary<int, SharedStruct>();
-        }
-
-        public void ping()
-        {
-            Console.WriteLine("ping()");
-        }
-
-        public int add(int n1, int n2)
-        {
-            Console.WriteLine("add({0},{1})", n1, n2);
-            return n1 + n2;
-        }
-
-        public int calculate(int logid, Work work)
-        {
-            Console.WriteLine("calculate({0}, [{1},{2},{3}])", logid, work.op, work.num1, work.num2);
-            int val = 0;
-            switch (work.op)
-            {
-                case Operation.ADD:
-                    val = work.num1 + work.num2;
-                    break;
-
-                case Operation.SUBTRACT:
-                    val = work.num1 - work.num2;
-                    break;
-
-                case Operation.MULTIPLY:
-                    val = work.num1 * work.num2;
-                    break;
-
-                case Operation.DIVIDE:
-                    if (work.num2 == 0)
-                    {
-                        InvalidOperation io = new InvalidOperation();
-                        io.what = (int)work.op;
-                        io.why = "Cannot divide by 0";
-                        throw io;
-                    }
-                    val = work.num1 / work.num2;
-                    break;
-
-                default:
-                    {
-                        InvalidOperation io = new InvalidOperation();
-                        io.what = (int)work.op;
-                        io.why = "Unknown operation";
-                        throw io;
-                    }
-            }
-
-            SharedStruct entry = new SharedStruct();
-            entry.key = logid;
-            entry.value = val.ToString();
-            log[logid] = entry;
-
-            return val;
-        }
-
-        public SharedStruct getStruct(int key)
-        {
-            Console.WriteLine("getStruct({0})", key);
-            return log[key];
-        }
-
-        public void zip()
-        {
-            Console.WriteLine("zip()");
-        }
-    }
-
-    public class CSharpServer
-    {
-        public static void Main()
-        {
-            try
-            {
-                CalculatorHandler handler = new CalculatorHandler();
-                Calculator.Processor processor = new Calculator.Processor(handler);
-                TServerTransport serverTransport = new TServerSocket(9090);
-                TServer server = new TSimpleServer(processor, serverTransport);
-
-                // Use this for a multithreaded server
-                // server = new TThreadPoolServer(processor, serverTransport);
-
-                Console.WriteLine("Starting the server...");
-                server.Serve();
-            }
-            catch (Exception x)
-            {
-                Console.WriteLine(x.StackTrace);
-            }
-            Console.WriteLine("done.");
-        }
-    }
-}
+using System;
+using System.Collections.Generic;
+using Thrift.Server;
+using Thrift.Transport;
+
+namespace CSharpTutorial
+{
+    public class CalculatorHandler : Calculator.Iface
+    {
+        Dictionary<int, SharedStruct> log;
+
+        public CalculatorHandler()
+        {
+            log = new Dictionary<int, SharedStruct>();
+        }
+
+        public void ping()
+        {
+            Console.WriteLine("ping()");
+        }
+
+        public int add(int n1, int n2)
+        {
+            Console.WriteLine("add({0},{1})", n1, n2);
+            return n1 + n2;
+        }
+
+        public int calculate(int logid, Work work)
+        {
+            Console.WriteLine("calculate({0}, [{1},{2},{3}])", logid, work.op, work.num1, work.num2);
+            int val = 0;
+            switch (work.op)
+            {
+                case Operation.ADD:
+                    val = work.num1 + work.num2;
+                    break;
+
+                case Operation.SUBTRACT:
+                    val = work.num1 - work.num2;
+                    break;
+
+                case Operation.MULTIPLY:
+                    val = work.num1 * work.num2;
+                    break;
+
+                case Operation.DIVIDE:
+                    if (work.num2 == 0)
+                    {
+                        InvalidOperation io = new InvalidOperation();
+                        io.what = (int)work.op;
+                        io.why = "Cannot divide by 0";
+                        throw io;
+                    }
+                    val = work.num1 / work.num2;
+                    break;
+
+                default:
+                    {
+                        InvalidOperation io = new InvalidOperation();
+                        io.what = (int)work.op;
+                        io.why = "Unknown operation";
+                        throw io;
+                    }
+            }
+
+            SharedStruct entry = new SharedStruct();
+            entry.key = logid;
+            entry.value = val.ToString();
+            log[logid] = entry;
+
+            return val;
+        }
+
+        public SharedStruct getStruct(int key)
+        {
+            Console.WriteLine("getStruct({0})", key);
+            return log[key];
+        }
+
+        public void zip()
+        {
+            Console.WriteLine("zip()");
+        }
+    }
+
+    public class CSharpServer
+    {
+        public static void Main()
+        {
+            try
+            {
+                CalculatorHandler handler = new CalculatorHandler();
+                Calculator.Processor processor = new Calculator.Processor(handler);
+                TServerTransport serverTransport = new TServerSocket(9090);
+                TServer server = new TSimpleServer(processor, serverTransport);
+
+                // Use this for a multithreaded server
+                // server = new TThreadPoolServer(processor, serverTransport);
+
+                Console.WriteLine("Starting the server...");
+                server.Serve();
+            }
+            catch (Exception x)
+            {
+                Console.WriteLine(x.StackTrace);
+            }
+            Console.WriteLine("done.");
+        }
+    }
+}
