Click here to Skip to main content
15,867,765 members
This competition has ended

Best C# article of October 2011

Contribute to CodeProject and you'll automatically be in the running for a monthly prize!

Each month at CodeProject we gather together the best of the articles submitted the previous month and ask our readers to choose the best of the best. Entry is automatic - just submit you articke and we'll do the rest.

Check out the submission guidelines for information on posting articles.

Current Entries

Articles that match the contest criteria are automatically entered. The top 50 entries are shown.

Please Sign up or sign in to vote.
30 Oct 2011jim lahey
In response to Adrian Cole's comment to the OP - due to living and working in a country where there are four official languages, plus English as a de facto fifth, I've encountered this before.Provided you have the corresponding .resx files embedded in the same assembly as the enum and your...
Please Sign up or sign in to vote.
18 Oct 2011Andrew Rissing
Or you could just go the other direction and cache the known results ahead of time. You're only looking at 13 numbers in all, so it is not a big memory hog to just store those known values inside of the method and be done with it.static uint Factorial(uint x){ if (x > 12) throw...
Please Sign up or sign in to vote.
18 Oct 2011George Swan
The Regex method uses comma, full stop, hyphen, and apostrophe as word separators. The problem with this is that these characters are not universally used as separators. The hyphen is used to join two words. Could I suggest the following?string input = "Mr O'Brien-Smith arrived at 8.30 and...
Please Sign up or sign in to vote.
23 Oct 2011jkrebsbach
A way to combine data from two different sources into one datasource for SSRS reporting
Please Sign up or sign in to vote.
28 Oct 2011Yvan Rodrigues
The Open Graph protocol specifies additional meta tags that can be added to the page to supplement social networking sites with more information about your page.
Please Sign up or sign in to vote.
14 Oct 2011Julien Villers
Nice tip! I'm also a proponent of using your friend the preprocessor to stop you from making big mistakes, along with your best friend, the compiler.You can combine both using this alternative code:private bool ValidateUserDetails(string userName, string password){ //TODO: Default value...
Please Sign up or sign in to vote.
5 Nov 2011Frank Augustin
Describe validation when presenting data in WPF Toolkit’s DataGrid.
Please Sign up or sign in to vote.
17 Oct 2011Ankush Bansal
C# Polymorphic types conversion with Generics
Please Sign up or sign in to vote.
25 Oct 2011KeithAMS
I am writing a service at present and have written a few over the years. What I do now is put all the code in a separate DLL from the start off. My service methods Onstart, OnStop call into the DLL which starts a thread to do the work.For debugging, I have a separate test harness console app...
Please Sign up or sign in to vote.
18 Oct 2011Sergio Andrés Gutiérrez Rojas
Easy FTP Upload without files size limit
Please Sign up or sign in to vote.
16 Oct 2011Panos Rontogiannis
For reference types, the hash is based on an internal counter that is incremented every time a descendant of System.Object is created. This happens in System.Object's constructor.For value types (structs), the hash is based on the first field. So if the first field is immutable, then you don't...
Please Sign up or sign in to vote.
20 Oct 2011jim lahey
I prefer to use ToTraceString() on the ObjectQuery:http://msdn.microsoft.com/en-us/library/system.data.objects.objectquery.totracestring.aspx[^]It's less intrusive as I don't have to instantiate and dispose the StreamWriter and I have more control over where and how I log the resultant...
Please Sign up or sign in to vote.
24 Oct 2011AlexCode 1 alternative  
Adding support for IHttpHandler on ASP.NET Routing
Please Sign up or sign in to vote.
23 Oct 2011zenwalker1985
I find Organize Usings -> Remove and Sort option much more useful than Just using Remove Usings. After it sorts, the using statements looks nice. :) In case you don't want to install any addins.
Please Sign up or sign in to vote.
30 Oct 2011A. Duman 1 alternative  
Usage of a TrackBar as a ToolStripMenuItem
Please Sign up or sign in to vote.
2 Oct 2011Gary Bilkus
How to get Silverlight 4 to display dates by default using the regional settings in the Control Panel.
Please Sign up or sign in to vote.
9 Oct 2011Luc Pattyn
This is an alternative to "Partial DateTime Object Equality".
Please Sign up or sign in to vote.
12 Oct 2011Rupesh Kumar Tiwari
I have below suggestions:1) Why are you making call to webmethod are you fetching data from server and showing it in tool tip ? But in your example it seems that you are just returning the same data that you get from UI. If you are making some DB call and returning data to UI then its ok to...
Please Sign up or sign in to vote.
24 Oct 2011rj45 1 alternative  
Export whole page to Excel with infragistics
Please Sign up or sign in to vote.
19 Oct 2011Manjuke Fernando
This is a common issue that development teams face when reports are being deployed to the production environment.
Please Sign up or sign in to vote.
25 Oct 2011Jacobs76
I also use a Regex expression to count words, which returns the same number of words as MS Word. I wrap the Regular Expression in a String extension method to make it easy to use.public static class StringExtensions{ /// /// WordCounts Regular Expression /// ...
Please Sign up or sign in to vote.
25 Oct 2011jim lahey
Along similar lines to KeithAMS, when writing a Windows service, I only use the Windows Service Project as a container to run code that is in one or more referenced assemblies. As far as I'm concerned, if I've got any logic that goes beyond starting and stopping the service in my service...
Please Sign up or sign in to vote.
25 Oct 2011orouit
This article demonstrates how to write a licensing provider for .NET licensing that gets licenses from a Gemalto .NET Card V2.
Please Sign up or sign in to vote.
30 Oct 2011Marvin Bland
The other option to review when you receive this error is to view your Application_Pools setting for the app_pool you are using for your application.Check the "Enable 32-Bit Applications". If this is "False", change it to "True". This may resolve your issue.
Please Sign up or sign in to vote.
2 Oct 2011Mohammad A Rahman
Rename all the files from the given folder using C#. The code will go through all the files and rename with the same name but with formatted name for example by removing "-" or "_" etc with given characters..
Please Sign up or sign in to vote.
2 Oct 2011Vishnu Kesaraju
Using LINQ to XML to convert datatables to formatted XML.
Please Sign up or sign in to vote.
4 Oct 2011kct
Here with generics:public static string ToString(this T obj, Func toStringFunction) { return toStringFunction(obj); }You can use it like this:Console.WriteLine(person.ToString(p=>p.Name));
Please Sign up or sign in to vote.
5 Oct 2011brad.ford@cudl.com
Why limit it to IList, instead of IEnumerable?public static class ListExtension{// This is unnecessary as any collection that implement IList will also implement IEnumerable// public static void ForEach(this IList list, Action function)// {// foreach (T...
Please Sign up or sign in to vote.
5 Oct 2011Rob2412
Eric,Thank...
Please Sign up or sign in to vote.
9 Oct 2011Colin3
Using the SAPBusinessObjects.WPF.Viewer.dll, the property ShowGroupTree is not available.To Hide the GroupTree as a default, set the property .ToggleSidePanel to SAPBusinessObjects.WPF.Viewer.Constants.SidePanelKind.None.e.g.With _viewer .IsEnabled = True ...
Please Sign up or sign in to vote.
7 Oct 2011Rob Lyndon
A utility class that lets you store a set of days of the week in a single int value
Please Sign up or sign in to vote.
10 Oct 2011zenwalker1985
Using the Facade Pattern to simplify application design
Please Sign up or sign in to vote.
19 Oct 2011zenwalker1985
Structural design pattern
Please Sign up or sign in to vote.
19 Oct 2011ARBebopKid
My preference for run-time speed is:long Factorial(int input){ if (input 1; input--) { if (long.MaxValue - answer
Please Sign up or sign in to vote.
13 Oct 2011zenwalker1985
Structural Design Pattern (Part 3)
Please Sign up or sign in to vote.
10 Jan 2013Pawel Gielmuda
How to set orientation to landscape mode for XNA game in mixed mode (Silverlight & XNA)
Please Sign up or sign in to vote.
18 Oct 2011BruceCarson
public class MsTSCLib2 : AxMSTSCLib.AxMsTscAxNotSafeForScripting{ public MsTSCLib2() : base() { } protected override void WndProc(ref System.Windows.Forms.Message m) { //Fix for the missing focus issue on the rdp client component if (m.Msg ==...
Please Sign up or sign in to vote.
20 Oct 2011zenwalker1985
Good practice in method design
Please Sign up or sign in to vote.
20 Oct 2011Colin Eberhardt
An implementation of IPagedCollectionView which allows paging of data from the server
Please Sign up or sign in to vote.
20 Oct 2011Manjuke Fernando
How to show properties of a class on a PropertyGrid
Please Sign up or sign in to vote.
24 Oct 2011Gary H Guo
Discusses the Fluent interface to register aspects to a component and a method to chain aspects to an object for AOP Container.
Please Sign up or sign in to vote.
26 Oct 2011Pascal Ganaye
Provides a couple of hash functions (string to int) that will return the same value in C# and T-SQL
Please Sign up or sign in to vote.
27 Oct 2011rj45
You can simplify this by doing the following:/// /// Render/// /// protected override void Render(HtmlTextWriter writer){ if (Session[ExcelExport] != null && bool.Parse(Session[ExcelExport].ToString())) { ...
Please Sign up or sign in to vote.
4 Oct 2011Horia Tudosie
See my article at Numeric Validator for Web Text Controls[^]
Please Sign up or sign in to vote.
4 Oct 2011Omar Al Zabir
You should add more ideas or at least edit the content significantly instead of copying and pasting from another article, my article that is:10 ASP.NET Performance and Scalability Secrets[^]==================There are several ASP.NET default HttpModules which sit in the request...
Please Sign up or sign in to vote.
5 Oct 2011Rob2412
Eric, sorry for the confusion, I think I wrote it too quick:Guillaume's library uses sRGB with D65 white ref. If you want to continue using that conversion, then just copy/paste RGBtoXYZ and XYZtoRGB into your code.you get a correct codethe calculation is more precise with the expanded...
Please Sign up or sign in to vote.
5 Oct 2011wvd_vegt
Here is some old Delphi code that you could use to get more out of floating points strings before using TryParse().It will sanitize numbers like .25E4 or 10.E2 or -.24, all illegal in Double.TryParse.The code will also replace all non-floating point characters by a decimal separator (the...
Please Sign up or sign in to vote.
5 Oct 2011Paulo Zemek
All classes are naturally Lazy loaded.So a better implementation will be:public class Singletonwhere T: new(){ public static readonly T Instance = new T();}You will notice that before calling the singleton class, the object will not be loaded.Surely there are...
18 Oct 2011Redgate Software
Identifying an application’s performance bottlenecks is all about understanding how the application is spending its time. Only with the most complete understanding of how an application is operating is it possible to understand what it is doing wrong, as this article describes.
Please Sign up or sign in to vote.
6 Oct 2011Go Cova
public static int GetFullWorkingDaysBetween(DateTime firstDate, DateTime lastDate, IEnumerable holidays){ if (firstDate > lastDate)// Swap the dates if firstDate > lastDate { DateTime tempDate = firstDate; firstDate = lastDate; lastDate =...

Current Participants

Those with articles that match the contest criteria are automatically entered.

Turkey Turkey
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Architect
Switzerland Switzerland
Senior IT Consultant working in Switzerland as Senior Software Engineer.

Find more at on my blog.
Architect
United States United States
Since I've begun my profession as a software developer, I've learned one important fact - change is inevitable. Requirements change, code changes, and life changes.

So..If you're not moving forward, you're moving backwards.
Software Developer (Senior)
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Software Developer State of Arkansas & Zycron
United States United States
Bryan Lee learned to code on a RadioShack Color computer II.
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Software Developer (Senior) Bluestone Consulting Group
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Architect Scott Logic
United Kingdom United Kingdom
I am CTO at ShinobiControls, a team of iOS developers who are carefully crafting iOS charts, grids and controls for making your applications awesome.

I am a Technical Architect for Visiblox which have developed the world's fastest WPF / Silverlight and WP7 charts.

I am also a Technical Evangelist at Scott Logic, a provider of bespoke financial software and consultancy for the retail and investment banking, stockbroking, asset management and hedge fund communities.

Visit my blog - Colin Eberhardt's Adventures in .NET.

Follow me on Twitter - @ColinEberhardt

-
New Zealand New Zealand
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
United States United States
Object-oriented (OO) is about "classes" not "objects". But I truly believe that "objects" deserve more our attentions. If you agree, read more on... Dynamic Object Programming (DOP), Component-Based Object Extender (CBO Extender), AOP Container and Dynamic Decorator Pattern.

Mobile development is not just another type of front end. The real challenge is actually in the back end: How to present meaningful information in time to mobile users with exponentially increased data flooding around? Here is my first mobile solution: SmartBars - Barcode Reader, Price Comparison and Coupons.

Gary lives in southeast Michigan. My first programming language is FORTRAN. For the last a few years, I have primarily focused on .NET technologies with Mobile Development as my newest interest.
Student
Wales Wales
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Web Developer ESRI.CA
Canada Canada
Horia Tudosie is Master of Sciences from the Polytechnic University of Bucharest - Computer Sciences.
Horia came in Canada in 1994 and have work in US 4 years since 2003.
He was working with various peculiar languages as Delphi and Forth, but mainly with C++, C#, WPF, and JavaScript. He mainly develops applications and Extensions for GIS.
Software Developer (Senior)
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Software Developer (Senior)
United Kingdom United Kingdom
First batch file in 1987

Messed around with the Bullfrog C++ Libraries for Syndicate in 1994

Web Developer since 2000

.net Developer since 2001

MCTS: Microsoft® .NET Framework 2.0 - Web-based Client Development

MCTS: Web Applications Development with Microsoft .NET Framework 4
Software Developer (Senior) Superior Consulting Services
United States United States
Jeff Krebsbach has been a Consultant with Superior Consulting Services (SCS) since 2006. SCS is based in Burnsville, Minnesota and focuses on developing solutions for Microsoft technologies, with a strong set of experience with MS SQL Server, SSRS, SSIS, and SSAS.
Software Developer (Senior) Frontier Developments
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
kct
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Software Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Software Developer (Senior)
Belgium Belgium
I am an engineer with a background in electronics, software and mathematics.

I develop technical software, both for embedded systems and for desktop equipment. This includes operating systems, communication software, local networks, image processing, machine control, automation, etc.

I have been using all kinds of microcontrollers and microprocessors (Intel 4004/8080/8051/80386/Pentium, Motorola 680x/680x0/ColdFire/PowerPC, Microchip PIC, Altera NIOS, and many more), lots of programming languages (all relevant assemblers, Fortran, Basic, C, Java, C#, and many more), and different operating systems (both proprietary and commercial).

For desktop applications and general development tools I have been using both UNIX systems and Mac/MacOS for many years, but I have switched to x86-based PCs with Windows, Visual Studio and the .NET Framework several years ago.

I specialize in:
- cross-platform development (making software that runs on diverse hardware/OS combinations)
- instruction set simulation
- improving software performance, i.e. making sure the software runs the job at hand in as short a time as possible on the given hardware. This entails algorithm selection, implementation design, accurate measurements, code optimisation, and sometimes implementing virtual machines, applying SIMD technology (such as MMX/SSE), and more.
Technical Lead Air Liquide Industrial Services (Singapore)
Singapore Singapore
My passion lies in building business intelligence and data-based solutions, writing about things I work with and talking about it. New technologies relevant to my line of work interest me and I am often seen playing with early releases of such technologies.

My current role involves architecting and building a variety of data solutions, providing database maintenance and administration support, building the organization’s data practice, and training and mentoring peers.

My aspiration over the next several years is to achieve higher competency and recognition in the field of Data Analytics and move into a career of data science.


Specialities: SQL Server, T-SQL Development, SQL Server Administration, SSRS, SSIS, C#, ASP.Net, Crystal Reports
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Software Developer
Australia Australia
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom
Architect Connect In Private
Singapore Singapore
Software Architect, COM, .NET and Smartcard based security specialist.

I've been working in the software industry since I graduated in Electrical and Electronics Engineering. I chose software because I preferred digital to analog.

I started to program with 6802 machine code and evolved to the current .NET technologies... that was a long way.

For more than 20 years I have always worked in technical positions as I simply like to get my hands dirty and crack my brain when things don't go right!

After 12 years in the smart card industry I can claim a strong knowledge in security solutions based on those really small computers!
I've been back into business to design the licensing system for the enterprise solution for Consistel using a .NET smart card (yes they can run .NET CLR!)

I'm currently designing a micro-payment solution using the NXP DESFire EV1 with the ACSO6 SAM of ACS. I can then add a full proficient expertise on those systems and NFC payments.
This technology being under strict NDA by NXP I cannot publish any related article about it, however I can provide professional consulting for it.

You can contact me for professional matter by using the forum or via my LinkedIn profile.
Software Developer
Greece Greece
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Software Developer (Senior)
France France
I am a French programmer.
These days I spend most of my time with the .NET framework, JavaScript and html.
Software Developer (Senior) Microsoft
United States United States
I started to program computers when I was 11 years old, as a hobbyist, programming in AMOS Basic and Blitz Basic for Amiga.
At 12 I had my first try with assembler, but it was too difficult at the time. Then, in the same year, I learned C and, after learning C, I was finally able to learn assembler (for Motorola 680x0).
Not sure, but probably between 12 and 13, I started to learn C++. I always programmed "in an object oriented way", but using function pointers instead of virtual methods.

At 15 I started to learn Pascal at school and to use Delphi. At 16 I started my first internship (using Delphi). At 18 I started to work professionally using C++ and since then I've developed my programming skills as a professional developer in C++ and C#, generally creating libraries that help other developers do their work easier, faster and with less errors.

Want more info or simply want to contact me?
Take a look at: http://paulozemek.azurewebsites.net/
Or e-mail me at: paulozemek@outlook.com

Codeproject MVP 2012, 2015 & 2016
Microsoft MVP 2013-2014 (in October 2014 I started working at Microsoft, so I can't be a Microsoft MVP anymore).
Software Developer ABB
Poland Poland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Red Gate Software Ltd.
United Kingdom United Kingdom
Redgate makes ingeniously simple software used by 804,745 IT professionals and counting, and is the leading Microsoft SQL Server tools vendor. Our philosophy is to design highly usable, reliable tools which elegantly solve the problems developers and DBAs face every day, and help them adopt database DevOps. As a result, more than 100,000 companies use products in the Redgate SQL Toolbelt, including 91% of those in the Fortune 100.
This is a Organisation

1 members
Software Developer (Senior)
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Software Developer (Senior) SpiegelSoft
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Software Developer (Senior)
United States United States

I am a Senior Software Developer working since 2005 in Microsoft ASP.Net and related Technologies.


I work on C#, Asp.Net, MVC, RAZOR, Entity Framework, JavaScript, jQuery, HTML5, CSS3, WCF, Silverlight, WPF, MVVM, SQL, SSIS, etc. Did Function Point Analysis, WBS to estimate projects and worked on Agile Scrum team.



I enjoy on exploring new technologies by implementing and writing about them, great interest in learning Design Patterns and their implementations. I love learning, writing JavaScript; now my favorite JavaScript library is jQuery. I enjoy writing jQuery Plugins and core JavaScript. I also write Technical blogs here. You can find me on LinkedIn.



I wrote an article on Swami Vivekananda posted his audio speeches by reading them.

Software Developer (Senior) Learn Production AI
Colombia Colombia
MSc. Artificial intelligence
Systems engineer
Senior software developer
Networks technologist
Artificial vision, AI and robotic lover
Technology enthusiast
Gamer

Learn Production AI founder
Motion Soft Co-founder
MIA PC Friend Developer

Take practical professional artificial vision courses (desktop and mobile) in Learn Production AI: https://www.learnproductionai.tech
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Web Developer Open Universiteit
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
Engineer Robotic Assistance Devices / AITX
Canada Canada
Yvan Rodrigues has 30 years of experience in information systems and software development for the industry. He is Senior Concept Designer at Robotic Assistance Devices

He is a Certified Technician (C.Tech.), a professional designation granted by the Institute of Engineering Technology of Ontario (IETO).

Yvan draws on experience as owner of Red Cell Innovation Inc., Mabel's Labels Inc. as Manager of Systems and Development, the University of Waterloo as Information Systems Manager, and OTTO Motors as Senior Systems Engineer and Senior Concept Designer.

Yvan is currently focused on design of embedded systems.
Software Developer (Senior) Siemens
India India
A .net developer since 4+ years, wild, curious and adventurous nerd.

Loves Trekking/Hiking, animals and nature.

A FOSS/Linux maniac by default Wink | ;)

An MVP aspirant and loves blogging -> https://adventurouszen.wordpress.com/
You must sign in to participate in this contest.
This contest has ended.
1 Oct - 31 Oct 2011