.net Writing your own Convert.ToBase64String in C# Have you ever wondered what Base64 is? How it works? Why you need it? Have you ever wanted to write your own Base64 encoder? Well, my friend, you are in luck because that’s what we’re talking about today. To get started… What is Base64? Base64 is a common
.net Converting a binary string to an int in C# Back in my previous post, Converting an int to a binary string [http://davidzych.com/2013/12/06/converting-an-int-to-a-binary-string-in-c/], we looked at how to write out the bits of an int without using the existing Convert.ToString [http://msdn.microsoft.com/en-us/library/14kwkz77%28v=vs.110%29.aspx] method
binary Converting an int to a binary string in C# The .NET Framework has a built in overload of Convert.ToString [http://msdn.microsoft.com/en-us/library/14kwkz77%28v=vs.110%29.aspx] which takes 2 parameters: the int you want to convert and an int of the base you want to convert to. Utilizing this with base 2, you
boxing When doing string concatenation in C#, why don't you have to call ToString on non string variables? To get the string representation of a variable, in this case we’ll use int, there is no implicit conversion from int to string so you can call the ToString method: string s = myInt; //INVALID!! string s = myInt.ToString(); // Valid! When concatenating with another string, though, you don’t have
fake Fake Organization, with Gmail A little while back, Google released an update to Gmail that included a new tabbed interface for your inbox. Google decided that [http://gmailblog.blogspot.com/2013/05/a-new-inbox-that-puts-you-back-in.html] sometimes it feels like our inboxes are controlling us, rather than the other way around and they set out to
surface Why I think Microsoft's new Surface 2 is great, and why it doesn't matter Microsoft this morning announced the Surface 2 and Surface Pro 2, the successor to their ever so popular [http://bgr.com/2013/07/26/ballmer-surface-rt-windows-8/] Surface RT and Surface Pro, respectively. I kept tabs on the announcement and overall I think Microsoft has made a good product even better: > Core
method Writing code using the Pseudocode Programming Process Are you a planner, or a doer? Most programmers I have seen tend to lean toward the doer side of things. This is generally great but can lead to some design issues down the road. Without properly designing a class or routine, you can run into situations where you have
carpal tunnel The Importance of Ergonomics - Mice In my first article in “The Importance of Ergonomics”, I went over the importance of the keyboard [http://davidzych.com/2013/06/25/the-importance-of-ergonomics-keyboards/] and how it can affect the health of your wrists, forearms and hands. In this article, I’ll cover mice (the computer kind), why the type
comments You have version control. So use it! How often do you see items like this when reviewing your source code: //We no longer display the count on the homepage //Uncomment this if we need it again! 8/20/2010 //for(int i = 0; i < maxResults; i++) //{ or… //Why is this commented? How are we getting the most
as Avoid using the is keyword in C# The C# language has the is [http://msdn.microsoft.com/en-us/library/scekt9xw%28v=vs.90%29.aspx] keyword which allows you to check if a variable is of a given type. if(myVar is MyClass) This is commonly helpful when dealing with a variable of type object, checking if
.net Was the .NET Framework a Failure? I’m a big, big fan of the .NET Framework. I have always felt that the whole framework is a very well thought out, organized and incredibly stable environment. I thoroughly enjoy developing for it and know a lot of people who feel the same way. That’s when I
hard drive Using mklink on Windows to move data off of SSDs I have had a solid state drive [http://en.wikipedia.org/wiki/Solid-state_drive] in my desktop computer at home for quite some time now, and just recently upgraded my machine at work to include one. It’s amazing how much faster your machine runs when you drop in an
C# Fun times with string.join in C# I had an interesting issue the other day at work regarding string.Join [http://msdn.microsoft.com/en-us/library/57a79xd0.aspx]. I had overridden ToString in one of my classes to easily output values from the object, and this new ToString implementation was utilizing string.Join: class Data { public string
alert Amber Alerts 2 nights ago as I was drifting off into dream land my wife’s phone suddenly started making noise. Not just a normal “I got a facebook message” noise, but a vibrating, beeping, “I’m pretty sure the Apocalypse [http://en.wikipedia.org/wiki/Apocalypse] is right around the corner”
C# Avoid Commenting Your Code When I’m answering questions on Stack Overflow [http://www.StackOverflow.com], I see a lot of questions with code like this: // Convert our ciphertext into a byte array. byte[] cipherTextBytes = encryptedBytes; ... // Create uninitialized Rijndael encryption object. TripleDESCryptoServiceProvider symmetricKey = new TripleDESCryptoServiceProvider(); ... // Define memory stream which will be used to hold
Google How Many Google Search Results Pages do you use? My general Googling (that’s a word, right? [http://en.wikipedia.org/wiki/Google_%28verb%29]) workflow goes something like this: 1. Hit CTRL + T in Chrome 2. Type my search query 3. Hit Enter 4. View first 3-4 results 1. If desired content is found, great! 5. If desired
ergonomics The Importance of Ergonomics - Keyboards Being programmers, we inherently spend a lot of time on our computers. Sitting in a proper position with your your workstation set up correctly is very important to your overall health. One of the most heard of and cataloged injuries from working on a computer is Carpal Tunnel Syndrome [http:
decrement C# Operator Precedence In my previous blog post on the difference between i++ and ++i [http://davidzych.com/2013/06/19/whats-the-difference-between-i-and-i-in-c/], I made a comment that i++ had a higher precedence than ++i. In C#, operators are grouped into categories and each category has a precedence. Categories with a higher precedence will
decrement What's the Difference Between i++ and ++i in C#? There’s common confusion between the difference of the Prefix (++i) and Postfix (i++) increment operators in C#. A common explanation would be that “The Prefix operator increases iprior to running the statement and the Postfix operator increases iafter running the statement.” Although this is the perceived functionality, it’s
enumerable LINQ GroupBy Explanations and Examples I’m a big fan of LINQ, and one of my favorite extension methods is GroupBy [http://msdn.microsoft.com/en-us/library/system.linq.enumerable.groupby.aspx]. I have found that GroupBy is one of the most useful methods in LINQ and the more I use it the more useful