Enumeration.

Slides:



Advertisements
Similar presentations
Pemrograman VisualMinggu …6… Page 1 MINGGU Ke Enam Pemrograman Visual Pokok Bahasan: Module, Class & Methods Tujuan Instruksional Khusus: Mahasiswa dapat.
Advertisements

Enumeration Data Type enum Day {SUN, MON, TUE, WED, THU, FRI, SAT}; Day today; today = WED; if (today == FRI) cout
1 Lab Session-III CSIT121 Fall 2000 Setting Your Own Paths Setting Project Information Browse Information Generation Data types revisited Enumerated data.
COMP102 – Programming Fundamentals I LA2B (Mon 5-7pm) LA2E (Fri 3-5pm) LA2F (Fri 5-7pm) TA: Jackie Lo.
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
Data Type. A data type defines a set of values that a variable can store along with a set of operations that can be performed on that variable. Common.
CS 355 – Programming Languages
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
.NET Data types. Introduction ٭ A "data type" is a class that is primarily used just to hold data. ٭ This is different from most other classes since they're.
BİL528 – Bilgisayar Programlama II
Other Types in OOP Enumerations, Structures, Generic Classes, Attributes Svetlin Nakov Technical Trainer Software University
CH2 – Using Data. Constant Something which cannot be changed Data Type Format and size of a data item Intrinsic Data Types Pg. 47 – Table 2-1 Basic ones.
Chapter 6 Fundamental Types Dept of Computer Engineering Khon Kaen University.
Chapter 2: Using Data.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
C# C1 CSC 298 Elements of C# code (part 1). C# C2 Style for identifiers  Identifier: class, method, property (defined shortly) or variable names  class,
Programming Fundamentals. Today’s Lecture The Conditional Operator Logical Operators Structures Enumerations.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
Ch Chapter 4 Basic Data Types and Variables 4.1 Basic Data Types In C TABLE 4.1 Introduction to Basic Data Types in C Type SizeDescription char 1.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 CMPE-013/L Enumerations Gabriel Hugh Elkaim Spring 2013.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Craps Game Application Introducing Random-Number Generation and Enum.
CS 1430: Programming in C++.
1.2 Primitive Data Types and Variables
COMP102 Lab 111 COMP 102 Programming Fundamentals I Presented by : Timture Choi.
Computer Programs CS 1400 Dennis A. Fairclough Version 1.1 CS 1400 Dennis A. Fairclough Version 1.1.
Programming Fundamentals Enumerations and Functions.
Chapter 6. Character String Types It is one in which the values consists of sequences of characters. How to Define a variable contain a string? In a programming.
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
Enumeration Types Managing Ordered Sets. Enumeration types are designed to increase the readability of programs Used to define a set of named constants.
5 Day Forecast Mon Tues Wed Thu Fri.
LESSON 06.
Chapter 6 – Data Types CSCE 343.
Enumerated Data Types Data type created by programmer
© 2016, Mike Murach & Associates, Inc.
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Module 5: Common Type System
Lecture 16: Introduction to Data Types
Computing with C# and the .NET Framework
សាកលវិទ្យាល័យជាតិគ្រប់គ្រង National University of Management
GANTT CHARTS Example Example Example Example text Tasks Example 1
Mon – 2Tue – 3Wed – 4Thu - 5Fri - 6Sat - 7Sun - 8 Mon – 9Tue – 10Wed – 11Thu - 12Fri – 13Sat – 14Sun -15 Mon – 16Tue – 17Wed – 18Thu - 19Fri – 20Sat –
DATA HANDLING.
MON TUE WED THU
1   1.テキストの入れ替え テキストを自由に入れ替えることができます。 フチなし全面印刷がおすすめです。 印刷のポイント.
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
January Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
2008 Calendar.
S M T W F S M T W F
January MON TUE WED THU FRI SAT SUN
Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
Sun Mon Tue Wed Thu Fri Sat
1/○~1/○ weekly schedule MON TUE WED THU FRI SAT SUN MEMO
January MON TUE WED THU FRI SAT SUN
A3 1.1c To Multiply & Divide Positive & Negative Numbers
S M T W F S M T W F
2016 | 10 OCT SUN MON TUE WED THU FRI SAT
Sun Mon Tue Wed Thu Fri Sat
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
WEB PAGES: Tables Welcome Back !.
1 January 2018 Sun Mon Tue Wed Thu Fri Sat
Structures Chapter 4.
2008 Calendar.
Presentation transcript:

Enumeration

Definition An enumeration is a set of related constants that define a value type where each constant is known as a member of the enumeration. The enumerations provided by the .NET Framework are generally used to set object properties and to specify the values that are passed to methods.

What is Enum An Enum is a value type with a set of related named constants often referred to as an enumerator list. The Enum keyword is used to declare an enumeration. It is a primitive data type, which is user defined.

Enum Enums type can be Integer (Decimal, Short, Byte, Double etc.). To use one of the integer data types, you can code an As clause that specifies the data type after the enumeration name. Enum is used to create numeric constants in .NET framework. All member of Enum are of Enum type.

Syntax of Enumeration Enum userdefinedname     member name 1[=value]     member name 2[=value] End Enum

Example of Enumeration Enum DayOfWeek         Sun         Mon         Tue         Wed         Thu         Fri         Sat     End Enum

Enumeration An enumeration defines a set of related constants. Each constant is known as a member of the enumeration. To specify other values for the constants, you can code an equal sign after the constant name followed by the integer value.

Example program of Enumeration Module Module1     Enum DayOfWeek         Sun         Mon         Tue         Wed         Thu         Fri         Sat     End Enum     Sub Main()      

Example Cont., Console.WriteLine("Day of week " & CInt(DayOfWeek.Sun) & " is " & DayOfWeek.Sun.ToString())         Console.WriteLine("Day of week " & CInt(DayOfWeek.Mon) & " is " & DayOfWeek.Mon.ToString())         Console.WriteLine("Day of week " & CInt(DayOfWeek.Tue) & " is " & DayOfWeek.Tue.ToString())         Console.WriteLine("Day of week " & CInt(DayOfWeek.Thu) & " is " & DayOfWeek.Wed.ToString())         Console.WriteLine("Day of week " & CInt(DayOfWeek.Fri) & " is " & DayOfWeek.Thu.ToString())         Console.WriteLine("Day of week " & CInt(DayOfWeek.Sat) & " is " & DayOfWeek.Fri.ToString())         Console.ReadLine()     End Sub End Module

Output

Some points about Enum Enums are enumerated data type in VB.NET. Enums are not for end-user, they are meant for developers. Enums are strongly typed constant. They are strongly typed, i.e. an Enum of one type may not be implicitly assigned to an Enum of another type even though the underlying value of their members are the same. Enumerations (Enums) make your code much more readable and understandable.

Cont., Enum values are fixed. Enum can be displayed as a string and processed as an Integer. The default type is Integer, and the approved types are Byte, Sbyte, Short, UShort, UInteger, Long, and ULong.

Cont., Every Enum type automatically derives from System. Enum and thus we can use System.Enum methods on Enums. Enums are value types and are created on the stack and not on the heap. The default and only access modifier supported is public.

The End …… Thank You ……