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

17
votes
3answers
3k views

Is c# actually a multiplatform language?

C# (and the .net platform in general) is looking like it's becoming a good option form multi-targeting apps : official MS .net framework : full blow windows development, asp.net dev, Windows phone ...
17
votes
3answers
13k 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
43k 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
2answers
517 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 ...
17
votes
1answer
1k 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 ...
16
votes
13answers
1k views

C# or .Net features to cut off assuming no backward compatibility needed? [closed]

Any product or framework evolves. Mainly it's done to catch up the needs of it's users, leverage new computing powers and simply make it better. Sometimes the primary design goal also changes with the ...
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
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 ...
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
11k 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
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
5answers
25k 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 ...
16
votes
5answers
2k views

What naming convention for C# file that contains multiple classes?

In C# projects, we frequently group small and tightly related classes into the same .cs file. This practice reduces the friction of dealing with a myriad of files containing close to no actual code. ...
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
6answers
15k 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.
16
votes
1answer
649 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 ...
15
votes
9answers
5k 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 ...
15
votes
8answers
12k 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
6k 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
2k 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
5answers
1k views

How would you teach C# delegate to a newbie? [closed]

I was reviewing Andrew Troelsen book on C# 4.0. The part that explains delegates starts as smooth as: public class SimpleMath { //declare delegate public delegate int BinaryOp(int x, int y); ...
15
votes
5answers
3k 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 ...
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
3answers
7k 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 ...
15
votes
4answers
1k 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> ...
15
votes
4answers
4k 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
1k 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 ...
15
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 ...
15
votes
6answers
1k 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
8answers
2k 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
3answers
914 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
1answer
327 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
519 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
7k 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 ...
14
votes
6answers
1k views

Should Properties have side effects

Should properties in C# have side effects beside notifying of a change in it's states? I have seen properties used in several different ways. From properties that will load the value the first time ...
14
votes
2answers
10k 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 ...
14
votes
13answers
1k views

async & await - poll for alternatives [closed]

Now that we know what is in store for c#5, there is apparently still an opening for us to influence the choice of the two new keywords for 'Asynchrony' that were announced by Anders Heijsberg ...
14
votes
3answers
765 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 ...
14
votes
5answers
889 views

Why isn't java used as a build language?

If Java is a general purpose language, and building a program is something that can be described using the Java language, why isn't this the best way to write build files and instead we use tools like ...
14
votes
3answers
3k views

Interception vs Injection: a framework architecture decision

There's this framework that I'm helping to design. There are some common tasks that should be done using some common components : Logging, Caching and raising events in particular. I am not sure if ...
14
votes
2answers
3k views

What are the main practices and design patterns every .NET guy should know?

In my brief time as a professional programmer I've seen lots of applications written by programmers who's entire education appears to have been reading the first couple of chapters in a .NET 2.0 book. ...
14
votes
5answers
10k views

Is There a Real Advantage to Generic Repository?

Was reading through some articles on the advantages of creating Generic Repositories for a new app (example). The idea seems nice because it lets me use the same repository to do several things for ...
14
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 ...
14
votes
7answers
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 ...
14
votes
2answers
921 views

Abstract exception super type

If throwing System.Exception is considered so bad, why wasn't Exception made abstract in the first place? That way, it would not be possible to call: throw new Exception("Error occurred."); This ...
14
votes
4answers
1k 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 ...
14
votes
2answers
3k 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 ...