C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform

learn more… | top users | synonyms

18
votes
2answers
573 views

Why does shared state degrade performance?

I've been working under the share-nothing principle of concurrent programming. Essentially, all my worker threads have immutable read-only copies of the same state which is never shared between them ...
18
votes
1answer
2k views

Async network programming using Reactive Extensions

After doing some (more-or-less) "low-level" async socket programming years ago (in an Event-based Asynchronous Pattern (EAP) fashion) and recently moving "up" to a TcpListener (Asynchronous ...
17
votes
9answers
8k views

Why are people so strongly opposed to #region tags in methods?

I hear a lot about keeping methods short and I've heard a lot of programmers say that using #region tags within a method is a sure sign that it is too long and should be refactored into multiple ...
17
votes
9answers
3k views

Will Java catch up with C#? [closed]

Today I posted a question asking about which language C# or Java would be better for me to study. I had some great answers. One thing that came up was that perhaps Java is now rather behind C# with ...
17
votes
11answers
8k views

Which Continuous Integration framework do you use and why? [closed]

There are quite a few different Continuous Integration (CI) frameworks out there and I'm wondering which is the most popular. Which frameworks have you used at firms where you work? Is there any ...
17
votes
14answers
3k views

Is there ever a reason to use an array when lists are available? [closed]

It seems like List<T> in C# can do everything an array can do and more, and seems also just as efficient in memory and performance as an array. So why would I ever want to use an array? I'm ...
17
votes
7answers
2k views

What can one do to improve readability of math-oriented code in C#, Java, and similar? [closed]

As both a C programmer and a C# programmer, one of the things I don't like about C# is how verbose math functions are. Every time you would have to use a Sin, cosine, or power function for example, ...
17
votes
9answers
609 views

Should if statments be in inner or outer method?

Which of these designs is better? What are the pros and cons of each? Which one would you use? Any other suggestions of how to deal with methods like is are appreciated. It is reasonable to assume ...
17
votes
9answers
5k views

Why hasn't C# gained much traction within the opensource community? [closed]

I'm not expecting C# to be on par with say Java or Python in the open source community, but it still surprises me just how far behind it is. 'Multi language' open source repos like google code or ...
17
votes
10answers
2k views

Best Practices and Etiquette for Setting up Email Notifications

If you were going to set up a Email Alerts for the customers of your website to subscribe to, what rules of etiquette ought to be followed? I can think of a few off the top of my head: Users can ...
17
votes
6answers
32k views

.NET Properties - Use Private Set or ReadOnly Property?

In what situation should I use a Private Set on a property versus making it a ReadOnly property? Take into consideration the two very simplistic examples below. First example: Public Class Person ...
17
votes
2answers
15k views

Creating database connections - Do it once or for each query?

At the moment I create a database connection when my web page is first loaded. I then process the page and run any queries against that conection. Is this the best way to do it or should I be creating ...
17
votes
4answers
2k views

Is there a canonical source for learning C# and .NET internals?

I have been a C++ programmer for last several years with a bit of C# here and there. In my latest job, I work heavily on C#. I picked most of my C# by following the code-base or random google searches ...
17
votes
6answers
6k views

Aspect Oriented Programming: When to start using a framework?

I just watched this talk by Greg Young warning people to KISS: Keep It Simple Stupid. One of the things he suggested is that to do aspect-oriented programming, one does not need a framework. He ...
17
votes
6answers
18k views

Advantages and disadvantages to using XAML/C# or HTML5/JavaScipt for Metro apps? [closed]

I was just wondering if there are any major advantages or disadvantages to using either XAML/C# or HTML5/JavaScript for Metro Apps.
17
votes
7answers
1k views

Why should one want to disable compiler warnings?

This answer and the comments added to it show a way to disable several compiler warnings using #pragma directives. Why would one want to do that? Usually the warnings are there for a reason, and I've ...
17
votes
3answers
15k views

Best design for Windows forms that will share common functionality

In the past, I have used inheritance to allow the extension of Windows forms in my application. If all of my forms would have common controls, artwork, and functionality, I would create a base form ...
17
votes
6answers
51k views

How should data be passed between client-side Javascript and C# code behind an ASP.NET app?

I'm looking for the most efficient / standard way of passing data between client-side Javascript code and C# code behind an ASP.NET application. I've been using the following methods to achieve this ...
17
votes
1answer
703 views

Is C#-4.0 an open standard?

The Ecma-334 (ISO/IEC 23270:2006) standard corresponds to the version 2.0 of the language. Specification of version 4.0 is freely available from Microsoft, but Microsoft's open specifications list ...
16
votes
5answers
2k views

Use of keyword “Using” in C# interface

When I'm using C# to write some code and I define an interface using Visual Studio 2010, it always includes a number of "using" statements (as shown in the example) using System; using ...
16
votes
5answers
5k views

When and why you should use void (instead of i.e. bool/int)

I occasionally run into methods where a developer chose to return something which isn't critical to the function. I mean, when looking at the code, it apparently works just as nice as a void and after ...
16
votes
7answers
2k views

What is the correct order to read these books? [closed]

I'm a junior C# developer, I learned at home and now I got my first job :) I want to buy these books. But what is the correct order to read these books? Code Complete: A Practical Handbook of ...
16
votes
14answers
4k views

Understanding how Code works is the way to actually 'Learn' programming, right?

I have a friend who is struggling with learning how to program (he wants to make games; as do I). Several books, tutorials, etc. His mentality is he has to memorize the code itself, as in the exact ...
16
votes
5answers
13k views

Multiple classes in a single .cs file - good or bad?

Is it advisable to create multiple classes within a .cs file or should each .cs file have an individual class? For example: public class Items { public class Animal { } public class ...
16
votes
3answers
851 views

Detecting IEnumerable “State Machines”

I just read an interesting article called Getting too cute with c# yield return It made me wonder what the best way is to detect whether an IEnumerable is an actual enumerable collection, or if it's ...
16
votes
3answers
10k views

What is constructor injection?

I have been looking at the terms constructor injection and dependency injection while going through articles on (Service locator) design patterns. When I googled about constructor injection, I got ...
16
votes
9answers
4k views

Whether to put the business logic in Stored Procedure or Not?

There is always a debate over the topic - "Whether to put the business logic in Stored Procedure or Not?". If we decide not to use the ORM Tool and not to put the Business Logic in Stored Procedure ...
16
votes
2answers
10k views

Separating data access in ASP.NET MVC

I want to make sure I'm following industry standards and best practices with my first real crack at MVC. In this case, it's ASP.NET MVC, using C#. I will be using Entity Framework 4.1 for my model, ...
16
votes
4answers
2k views

Is the “Gets or sets ..” necessary in XML documentation of properties?

I am looking for a recommendation of a best practice for XML comments in C#. When you create a property, it seems like that the expected XML documentation has the following form: /// <summary> ...
16
votes
6answers
2k views

How to hire a good C# developer if I don't know C#?

I'm a C++ developer. I know how Windows works on the native level, but I'm not a big expert in C# and .NET. Now I need a C# developer in my team (all my developers are C++). How can I hire a great C# ...
16
votes
11answers
3k views

How does one meaningfully measure maintainability?

Context: I'm an enterprise developer in an all-MS shop. Can anyone recommend a good way of objectively measuring maintainability of a piece of code or an application? Why maintainability: I'm tired ...
16
votes
6answers
2k views

When should I use a 2-property class over a pre-built structure like a KeyValuePair?

When should you put Key/Value type of data in it's own class instead of using a pre-built generic structure, such as a KeyValuePair or a Tuple? For example, most ComboBoxes I create contain a ...
16
votes
8answers
3k views

What do you do when a client requires Rich Text Editing on their website?

As we all know by now, XSS attacks are dangerous and really easy to pull off. Various frameworks make it easy to encode HTML, like ASP.NET MVC does: <%= Html.Encode("string"); %> But what ...
15
votes
8answers
13k views

Senior Interview LINQ questions [closed]

I'm preparing a LINQ section in interview questions for senior programmers. What are the most interesting questions in LINQ to include? And why?
15
votes
8answers
7k views

Do I need a degree in Computer Science to get a junior Programming job? [closed]

Do I need to go to Uni to get a job as a Junior C# coder? I'm 26 and have been working in Games (Production) for 6 years and I am thinking of a change, I've had exposure to VB6, VBA, HTML, CSS, PHP, ...
15
votes
3answers
1k views

Is it poor practice to name a property/member the same as the declaring type in C#?

For instance, a class like: class Dog { } //never mind that there's nothing in it... and then a property like: Dog Dog { get; set; } I've been told that if I can't come up with a more ...
15
votes
10answers
3k views

Declaring interface in the same file as the base class, is it a good practice?

To be interchangable and testable, normally services with logic needs to have interface, e.g. public class FooService: IFooService { ... } Design-wise, I agree with this, but one of the things ...
15
votes
11answers
2k views

Should I break contract early? [closed]

About 7 months ago I made the switch from a 5 year permie role (as a support developer in C#) to a contract role. I did this because I was stagnating in my old role. The extra cash contracting is ...
15
votes
14answers
2k views

Explaining interfaces to beginning programmers?

I've had discussions with other programmers on interfaces (C#). I tried to use the analogy of interfaces being like a contract between programmers. Meaning that when you design to an interface, you ...
15
votes
4answers
5k views

Using static classes as namespaces

I have seen other developers using static classes as namespaces public static class CategoryA { public class Item1 { public void DoSomething() { } } public class Item2 { ...
15
votes
6answers
2k views

From Delphi to C# for Dummies

I'm a Delphi and C# coder and have been given the assignment to introduce the most fundamental concepts of .Net/C# to my coworkers in some trainings. They are seasoned Delphi Win32 coders but still ...
15
votes
3answers
6k views

How will C# 5 async support help UI thread synchronization issues?

I heard somewhere that C# 5 async-await will be so awesome that you will not have to worry about doing this: if (InvokeRequired) { BeginInvoke(...); return; } // do your stuff here It looks ...
15
votes
6answers
2k views

Why is closure important for JavaScript?

C#'s lambda expression also has closures but is rarely discussed by the C# communities or books. I see far more JavaScript people and books talk about its closures than they do in the C# world. Why is ...
15
votes
3answers
4k views

Is there any real value in unit testing a controller in ASP.NET MVC?

I hope this question gives some interesting answers because it's one that's bugged me for a while. Is there any real value in unit testing a controller in ASP.NET MVC? What I mean by that is, most ...
15
votes
3answers
1k views

Does the state Pattern violate Liskov Substitution Principle?

This image is taken from Applying Domain-Driven Design and Patterns: With Examples in C# and .NET This is the class diagram for the State Pattern where a SalesOrder can have different states during ...
15
votes
4answers
2k views

How does persistence fit into a purely functional language?

How does the pattern of using command handlers to deal with persistence fit into a purely functional language, where we want to make IO-related code as thin as possible? When implementing ...
15
votes
2answers
4k views

c# class naming standards/guidelines

Over the years I've used various naming conventions for services in my applications for example: [ClassName]Service [ClassName]Manager [ClassName]Factory [ClassName]Provider ...
15
votes
1answer
349 views

Are there any examples of implementing and effectively responding to a “Chaos Monkey”?

Jeff Atwood recently wrote a blog post about Netflix's implementation of a "Chaos Monkey". It is a very high level article. I am curious if anyone has actually implemented this technique for testing a ...
15
votes
1answer
530 views

Best way to share / “donate” a C# software - and what license? [closed]

Some years back I have developed a little C# class library, which is still frequently downloaded. Since I do not have the time to support the project any more, I would like to donate it. What is the ...
14
votes
10answers
8k views

Should we choose Java over C# for a new project? [duplicate]

We have a team of .NET developers (C#) with a range of experience from 2 to 6 years. Over the last few years we have been developing Silverlight, ASP.NET MVC, and WPF applications. However, there is a ...