Geeks With Blogs

News View Steve Michelotti's profile on LinkedIn

Mark Pearl C#
Refactoring FizzBuzz
A few years ago I blogged about FizzBuzz, at the time the post was prompted by Scott Hanselman who had podcasted about how surprized he was that some programmers could not even solve the FizzBuzz problem within a reasonable period of time during a job interview. Originally I thought I would give the problem a go in F# and sure enough the solution was fairly simple – I then also did a basic solution in C# but never posted it. Since then I have learned that being able to solve a problem and how you ......

Posted On Monday, October 15, 2012 7:58 PM

Getting App.config to be configuration specific in VS2010
I recently wanted to have a console application that had configuration specific settings. For instance, if I had two configurations “Debug” and “Release”, depending on the currently selected configuration I wanted it to use a specific configuration file (either debug or config). If you are wanting to do something similar, here is a potential solution that worked for me. Setting up a demo app to illustrate the point First, let’s set up an application that will demonstrate the most basic concept. using ......

Posted On Wednesday, April 4, 2012 10:35 AM

XAML Oddities – Inline C# code in a XAML file (aka UTCC approach)
Something I came across that I never knew was possible was that you can put c# code inline in a XAML file in a WPF app (I assume this would work in Silverlight as well). Not that you would ever want to do this, but sometimes you just need those geek points! Make a WPF application, in the XAML file put the following… <Grid> <Button x:Name="button1" Click="button1_click">te... <x:Code> void button1_click(object sender, RoutedEventArgs e) { button1.Content = "Inline Code ......

Posted On Tuesday, January 31, 2012 8:08 PM

Log4Net basics with a Console Application (c#)
If you are looking for a great introductory article on Log4Net, I would recommend reading the Log4Net tutorial by Tim Corey. Tim goes through quite a bit, I just want to cover the very bare minimum for getting log4net to work in a console application. Step 0 – Reference Log4Net Using NuGet this is really easy – but no matter how you do it, you should end up with a reference to log4net in your project. Step 1 – Add an entry to AssemblyInfo.cs Add the assembly for the log4net.config to AssemblyInfo.cs[assembly: ......

Posted On Monday, January 30, 2012 10:29 AM

Working with NDBUnit – my suggested project structure for removing complexity.
In the team that I have been working with lately they use NDBUnit to control the test database state for Integration Tests. Today I thought I would blog briefly on one of the issues we had and how we are going to go forward in the future in structuring our solution and working with NDBUnit. Let me say upfront that I am no expert with NDBUnit, so if you are an expert with this tool, and you can see glaring mistakes in this post, add a comment (I would appreciate that). That said, let me highlight ......

Posted On Friday, December 30, 2011 10:07 AM

C# soon to dethrone C++ as the third most popular language in the world
Every now and then I go to Tiobe to see their ratings on the popularity of programming languages. Usually there is nothing exciting out there, just a few small moves of languages so I was interested to see in December Tiobe had a headline of C++ about to be dethroned by C# Looking at the stats, sure enough, according to Tiobe C# is on the verge of taking the number 3 spot. It will be interesting to see what happens when Windows 8 hits the market with what seemed to be a revival of C++ during Microsoft’s ......

Posted On Wednesday, December 28, 2011 11:18 AM

Fix for NDbUnit - DbCommandBuilder.CreateSelectCommand(DataSet, string) failed for tableName = 'XXX'
I have recently been using NDbUnit for integration tests exercising the database. I am new to the tool, so the following exception caused a few hours of scratching my head before I figured out the obvious. Assume you are going through the quick start guide from the website, everything works perfectly. Then I changed to my production database and did the same thing and I get the following error…] DbCommandBuilder.CreateSele... string) failed for tableName = '…. Turns out the name of ......

Posted On Friday, December 9, 2011 2:05 PM

C# If Else Shortcut
Recently I participated in a local user group challenge which involved submitting a project that solved a problem with the fewest bytes. My end solution resulted in one long line of code that at first glance seemed like a series of symbols and letters. While I wouldn’t use such an approach in production code it was nice to go against everything I have been taught about naming and spacing. One optimization that we used was to simplify the if..then..else statement. In C# you could have the following ......

Posted On Wednesday, October 27, 2010 6:49 AM

Silverlight & WCF Real Basics
So I am not a web developer! I have never been one but Silverlight keeps popping in my head as the next big thing on the Microsoft stack and I would hate to “miss the boat” (I am sure some C developer said that 10 years ago as well). Today I thought I would get a little wet with Silverlight & WCF. Up to now I have been working in WPF so I am not scared of XAML and am surprised to say that I actually enjoy it. I have however never worked with WCF so for me that will be the learning curve. My project ......

Posted On Saturday, August 7, 2010 9:38 AM

Linq to XML to make a RSS Feed Reader in C#
Today I thought I would just list a little tutorial on how to make an RSS feed reader in C#. The code is very simple… public class RssFeedReader { public IEnumerable<Post> ReadFeed(string url) { var rssFeed = XDocument.Load(url); var posts = from item in rssFeed.Descendants("item") select new Post { Title = item.Element("title").Value, Description = item.Element("description")... PublishedDate = item.Element("pubDate").Value }; return posts; } } public class Post { public string PublishedDate; ......

Posted On Friday, December 2, 2011 6:38 AM

Copyright © MarkPearl | Powered by: