Coding Best Practices
Welcome to Performance & Best Practices section of C# Corner. In this section, you will find various Performance & Best Practices related source code samples, articles, tutorials, and tips.


  • dotNetDave Says… If Your Code Is Hard To Unit Test, You’re Doing It Wrong

    Unit testing is something very important for any project. With that said, I rarely see it done in projects or done correctly. How can you push the code to quality assurance or production without knowi
  • Best Coding Practices - Part One

    This blog sums up a few best practices while naming a variable/ method/ class.
  • Code Quality Is A Feature, Not An Afterthought

    In this article you will learn that code quality is a feature, not an afterthought.
  • C# Programming Performance Tips - Part Six - Array Length

    In this blog, we will see how to use Array.Length before iterating an array.
  • C# Programming Performance Tips - Part Five - List.Count() Vs List.Count

    In this blog, we will do the benchmarking for List.Count() method and List.Count property.
  • C# Programming Performance Tips - Part Four - List.Count() Vs List.Any()

    In this blog, we will compare the execution time between List.Count() and List.Any().
  • C# Programming Performance Tips - Part Three - Adding Strings

    In this blog, we will see a better way of adding two or more string variables.
  • C# Programming Performance Tips - Part Two - String Equals

    In this blog, we will see how we can avoid null reference exception while using the String.Equals method.
  • C# Programming Performance Tips - Part One - String Split

    In this blog, we will see the usage of String.Split method in a optimized way.
  • Some Real Differences Between Structures and Classes

    This article lists some differences between classes and structures. In this article, we will see what is the difference between a structure and a class.
  • All About OWASP #3 - Sensitive Data Exposure

    In this part of the study of OWASP Top 10 Threats, we will understand Threat # 3 – Sensitive Data Exposure.
  • All About OWASP #1 - SQL Injection Attack

    Considering security as the most important aspect of an application and as the First step in SOUND Programming Methodology, we will be covering SQL Injection Attack and Prevention.
  • All About OWASP #2 - Broken Authentication

    In this article, we will learn about Secure Programming of SOUND programming methodology. We will cover Broken Authentication from OWASP's top 10 security threats.
  • An Effective Coding And Code Review Technique

    Coding and Code review are the most basic building blocks of any software product. Any lapse may severely affect the schedule, quality, and of course the cost. Not only in the review but a few issues
  • Quick Tips For Writing Clean Code - Part Two

    This blog aims at writing clean code and avoiding some common mistakes that programmers usually make while writing code.
  • Quick Tips for writing Clean Code Part-1

    This blog aims on writing clean code and avoid some common mistakes that programmers usually make while writing code.
  • Generics in C# 2.0

    In this article, I specifically talk about Generics and how they improve upon arraylists and how they solve the issues posed by ArrayLists.
  • C# Heap(ing) Vs Stack(ing) In .NET - Part Three

    Having a basic understanding of how memory management works will help explain the behavior of the variables we work with in every program we write. In this article we’ll cover an issue that arises fr
  • Best Practices No 5: Detecting .NET application memory leaks

    In this article we are going to detect the .NET application memory leaks.
  • Is Something Wrong With OOP?

    This blog will discuss a few critical points about OOP and we'll be seeing another way to define it.
  • Ineffective Coding Habits - What To Avoid

    In this article, I'll be talking about some habits of programmers which are not so effective. We'll be looking into what to avoid and how to code effectively.
  • Presenting Code Samples With A Dark Theme...Please Do Not

    For all of you who code using apps like Visual Studio or VS Code, please don’t present code in a meeting or conference session using a dark theme! I know I am going to get a lot of push back from this
  • Handling Arithmetic Overflow

    When you are dealing with integer values which are in higher amounts, you might arrive at a situation where the program gives you the wrong output.
  • String and StringBuilder Classes

    Here I'm going to tell you about what is String and StringBuilder and what the differences between String and StringBuilder classes.
  • How To Write Effective Code

    How To Write Effective Code. The key to writing effective code is Delete Unnecessary Code, use clean code, learn coding from masters, Meaningful Code Commenting, Debug code and Trace, Unit Testing, ef
  • View More