Conversions:Numeric Types:Conversions and Member Lookup


   
  

using System;

class Conv
{
    public static void Process(sbyte value)
    {
        Console.WriteLine("sbyte {0}", value);
    }
    public static void Process(short value)
    {
        Console.WriteLine("short {0}", value);
    }
    public static void Process(int value)
    {
        Console.WriteLine("int {0}", value);
    }
}

public class ConversionsandMemberLookup
{
    public static void Main()
    {
        int    value1 = 2;
        sbyte    value2 = 1;
        Conv.Process(value1);
        Conv.Process(value2);
    }
}

           
         
    
     


Casting int float and byte

   
  
/*
 * C# Programmers Pocket Consultant
 * Author: Gregory S. MacBeth
 * Email: gmacbeth@comporium.net
 * Create Date: June 27, 2003
 * Last Modified Date:
 * Version: 1
 */
using System;

namespace Client.Chapter_1___Common_Type_System
{
  public class Casting
  {
    static void Main(string[] args)
    {
      int MyInt = 12345;
      long MyLong = MyInt;  
      short MyShort = (short)MyInt;
    }
  }
}