«^»
3.3. Differences from Java

We now look at some of the ways in which C# and Visual Basic.NET are different from Java.

Here is an example of a struct type coded in C#:

namespace First
{
    public struct SPoint
    {
        private int iX;
        private int iY;
        public SPoint(int pX, int pY)
        {
            iX = pX;
            iY = pY;
        }
        public override string ToString()
        {
            return iX + ":" + iY;
        }
    }
}

Here is a method that uses this struct type:

using System;
namespace First
{
    public class SPointTest
    {
        public static void Main()
        {
            SPoint tSPoint = new SPoint(100, 200);
            Console.WriteLine(tSPoint);
            SPoint tAnotherSPoint = tSPoint;
            Console.WriteLine(tAnotherSPoint);
        }
    }
}

3.3.1. Types

3.3.2. Methods

The following kinds of parameters are available:

Java C# VB.NET
value value ByVal
ref ByRef
out
params

private static void Swap(ref int x, ref int y)
{
    int temp = x;
    x = y;
    y = temp;
}
...
i = 42;
j = 27;
Swap(ref i, ref j);
// i has the value 27
// j has the value 42

3.3.3. Statements

3.3.4. Properties, indexers and operator overloading

3.3.5. Delegates

3.3.6. Events

3.3.7. Exception handling