0% found this document useful (0 votes)
13 views

Application Foundation Lab 1 - Data Type Casting

This document provides instructions for a lab on type casting in C# and VB.NET. It instructs the user to create a new console application called "AUCProject2" in Visual Studio, then write code that assigns the short variable s to 255, casts s to a byte and stores it in b, and prints b to the console, which will output 255.

Uploaded by

M. Maaz Khan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Application Foundation Lab 1 - Data Type Casting

This document provides instructions for a lab on type casting in C# and VB.NET. It instructs the user to create a new console application called "AUCProject2" in Visual Studio, then write code that assigns the short variable s to 255, casts s to a byte and stores it in b, and prints b to the console, which will output 255.

Uploaded by

M. Maaz Khan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

LAB 1: Type Casting PART NO. 1 1.

Go to Start > All Programs > Microsoft Visual Studio > Microsoft Visual Studio 2010 2. Click File | New Project | C# or VB Tab |Console Application 3. From New Project Dialog Box select Console Application, set Location to File System and set appropriate location by clicking the Browse Button, set Language to your preferred programming Language. 4. Name the Project AUCProject2 5. Open Solution Explorer, select code file 6. VB.Net Programmer jump to line 7 and C# Programmer jump to line 8 7. Write following code in Modulle.vb file: Sub Main() Dim s As Short Dim b As Byte s = 255 b = Convert.ToByte(s) Console.WriteLine(b) Console.ReadLine() End Sub 8. Write following code in Program.cs static void Main(string[] args) { short s; byte b; s = 255; b = (byte)s; Console.WriteLine(b); Console.ReadLine(); }

9. Following will be output:

You might also like