C# Parameter Programming Example

In this chapter you will learn:

In this chapter you will see some programming examples of using parameter in C#.

Qu 1: Write a program to show difference between value type parameter and reference type parameter.


Enter a number: 9

Value Type

Previous Value: 9
Current Value: 9

Reference Type

Previous Value: 9
Current Value: 10

  • Qu2: Write a program in which accept two argument as parameter from the user and returns four output value as add, subtract, multiplication and division.


    Enter 1st number       7

    Enter 2nd number       9

    7 +9 = 16
    7 – 9 = -2
    7 * 9 = 63
    7 / 9 = 0.7777778


    Qu3: Write a program in which pass two number as command line argument and displays the multiplication of both number.

    a.Write the following command on notepad and save as commandline.cs

    b.Open visual studio command prompt and set current path of your program.
    c.Compile it as csc commandline.cs
    d.Now execute program as commandline 5 4


    Setting environment for using Microsoft Visual Studio 2008 x86 tools.

    C:\Program Files\MIcrosoft Visual Studio 9.0\VC>d:

    D:\>csc commandline.cs
    Microsoft <R> Visual C# 2008 Compiler version 3.5.30729.1
    for Microsoft <R> .NET Framework version 3.5
    Copyright <C> Microsoft Corporation. All rights reserved.

    D:\>commandline 5 4
    5 x 4 = 20

    D:\> __



    In this chapter you studied some programming examples of parameter. In next chapter you will do some programming exercises of parameter.

    One thought on “C# Parameter Programming Example”

    Leave a Reply

    Your email address will not be published. Required fields are marked *