Your First C# Program with a Function - CSharp Language Basics

CSharp examples for Language Basics:Hello World

Introduction

We can create reusable method that multiplies an integer by 12 as follows:

Demo Code

using System;/* w  ww  .  j a va  2  s. c o  m*/
class Test
{
   static void Main()
   {
      Console.WriteLine (FeetToInches (30));      // 360
      Console.WriteLine (FeetToInches (100));     // 1200
   }
   static int FeetToInches (int feet)
   {
      int inches = feet * 12;
      return inches;
   }
}

Result


Related Tutorials