Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  • Which are C# 4.0 programming paradigms?
  • In what category does extension methods fall into?

A programming language can support multiple paradigms. For example, programs written in C++ or Object Pascal can be purely procedural, or purely object-oriented, or contain elements of both paradigms.

In object-oriented programming, programmers can think of a program as a collection of interacting objects, while in functional programming a program can be thought of as a sequence of stateless function evaluations. When programming computers or systems with many processors, process-oriented programming allows programmers to think about applications as sets of concurrent processes acting upon logically shared data structures.

Just as different groups in software engineering advocate different methodologies, different programming languages advocate different programming paradigms.

Source: Wikipedia

share|improve this question

closed as too broad by Robert Harvey, Ampt, MichaelT, GlenH7, gnat Jan 15 '15 at 21:04

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

This question is very vague. Could you be more specific? – MatthewKing Mar 23 '11 at 8:10
@Joviee According to definition, there should be a handful of paradigms in any language. – Amir Rezaei Mar 23 '11 at 8:21
up vote 4 down vote accepted

C# done right is to use it in an object oriented way as the object oriented paradigm is it's main pillar. This has a heavy impact on your program structure, much more than the functional elements of C#.

You can use the functional elements (LinQ) when they make a solution to a problem easier to express, to simplifiy implementations. This feature/paradigm is not meant to structure a whole program.

For easy tasks, you can use C# in a purely imperative way.

But: C# should never be programmed in a procedural way (for example methods with many out arguments).

So, to answer your questions: C# is based upon an imperative, object oriented paradigm with declarative/functional elements.

Extension Methods are just syntactic sugar to extend an existing class, so you don't need to derive from it. I'd say they're an element of object oriented programming, as they allow you to work on instances of objects and they allow you to extend existing classes with external components.

share|improve this answer
Unfortunately C# doesn't support some of the really interesting functional aspect like currying functions. Sometimes I just really wish that some of the languages I use all the times supported this one really cool idea natively. I also wouldn't compare LINQ to functional programming. It's a great declarative way to process data, but it's not really functional programming. – Matthew Scharley Mar 23 '11 at 9:06
+1 For "imperative, object oriented paradigm with declarative/functional elements", and identifying functional part of C#. – Amir Rezaei Mar 23 '11 at 9:10
s\it's\its\g (I would edit it, but I don't find anything else substantial to edit, and one has to change 6 chars at least (stupid rule, isn't it ;-)) – fretje Mar 23 '11 at 9:12
@Matthew You can do currying functions. – Amir Rezaei Mar 23 '11 at 9:13
@Amir you can do it, but it's a pain, and it's not supported as a first class citizen. In languages like F# you can for instance call a function with two parameters with one, and instead of a result you will get back a function pointer that takes one parameter. – Matthew Scharley Mar 23 '11 at 9:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.