Delegates and functional programming in C#

  • Authors:
  • David R. Naugler

  • Affiliations:
  • Southeast Missouri State University, Cape Girardeau, MO

  • Venue:
  • Proceedings of the 2nd annual conference on Mid-south college computing
  • Year:
  • 2004

Quantified Score

Hi-index 0.00

Visualization

Abstract

In functional languages such as Scheme or ML functions can be passed as parameters, can be constructed in other functions and returned as values. This allows a style of programming that is quite distinct from that used with languages such as Pascal, C or C++. C# has interfaces but lacks anonymous inner classes which were used in [2] for functional programming in Java. Delegates allow fairly easy mimicking of some of the important features of functional programming in a rather different way than in Java. Using delegates and a class to model real functions, it is shown how to write functions that take functions as parameters and construct and return new functions. It is not advocated that functional programming be taught in C# languages such as ML are much superior for that task than C#. However, the above techniques allow students to use modes of thinking learned in the study of a functional languages directly in programs written in C#.