O'Reilly logo

C# for Financial Markets by Andrea Germani, Daniel J. Duffy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2

C# Fundamentals

2.1 INTRODUCTION AND OBJECTIVES

The goal of this chapter is to introduce the C# language. We concentrate on fundamental issues such as built-in data types, memory management and basic console input and output. Of particular importance is the distinction between value types and reference types, how they are created, compared and finally removed from memory.

Without further ado, we deliver the extremely popular “Hello World” program:

using System;	 // Use the System namespace (Console etc.)
// HelloWorld class. Every C# program has at least one class
public class HelloWorld
{ // Each Main method must be enclosed in a class
   // C# programs start in this Main() method
   public static void Main()
   {
	 // Write string to console
	 Console.WriteLine("Hello world!");
   }
}

In this case we have created a class called HelloWorld containing a method called Main() which is the entry point to the program. We explain this (and more extended) syntax in the rest of this chapter.

We are assuming that the reader has knowledge of programming in some object-oriented language, in particular what classes and objects are, some knowledge of data types and basic exception handling. For those readers with minimal programming experience and who need to learn fundamental C# syntax, please consult a book on C#, for example Albahari 2010. In this chapter we deliver a simple C# class that implements the Black Scholes equation. For an introduction to object-oriented programming, see Appendix ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required