UNIT I INTRODUCTION TO C#

Size: px
Start display at page:

Download "UNIT I INTRODUCTION TO C#"

Transcription

1 UNIT I INTRODUCTION TO C# Syllabus: Introducing C#, Understanding.NET, Overview of C#, Literals, Variables, Data Types, Operators, Expressions, Branching, Looping, Methods, Arrays, Strings, Structures, Enumerations. Introducing C# C# is to provide a simple, safe, modern, object-oriented, Internet-centric, high- performance language for.net development. The key features of C sharp programming language No pointers required! C# programs typically have no need for direct pointer manipulation (although you are free to drop down to that level if absolutely necessary). Automatic memory management through garbage collection. Given this, C# does not support a delete keyword. Formal syntactic constructs for classes, interfaces, structures, enumerations, and delegates. The C++-like ability to overload operators for a custom type, without the complexity (e.g., making sure to return *this to allow chaining is not your problem). Support for attribute-based programming. This brand of development allows you to annotate types and their members to further qualify their behavior. C# Language Features C# was developed as a language that would combine the best features of previously existing Web and Windows programming languages. Many of the features in C# language are preexisted in various languages such as C++, Java, Pascal, and Visual Basic. Here is a list of some of the primary characteristics of C# language. Modern and Object Oriented Simple and Flexible Typesafety Automatic Memory Management Versioning Control Cross Platform Interoperability Advanced features introduced in C# 2.0 and 3.0 a. Modern and Object Oriented A modern language is one that provides latest features and tools for developing scalable, reliable, and robust industry standard applications. C# is a modern language. The current trend in programming is

2 Web development, and C# is the best language for developing web application and components for the Microsoft.NET platform. As mentioned, C# is an object oriented language. It supports all the basic object oriented language features: encapsulation, polymorphism, and inheritance. b. Simple and Flexible C# is as simple to use as Visual Basic, in that everything in C# represented as an object. All data type and components in C# are objects. C++ programmers are sometimes confused when choosing different access operators to process object. With C# you use a dot (.) operator to access the object members. Programmers use C# to develop both managed and unmanaged code. Managed code is code managed through the CLR module. It handles garbage collection, type-safety, and platform-independence behavior. Unmanaged code, on the other hand is code run outside the CLR, such as an ActiveX control. C# provides the flexibility of using native Win 32 application programming interface (API) and unmanaged code through COM+. C# enables you to declare unsafe classes and members having pointers, COM interfaces, structures, and native APIs. Although the class and its member are not typesafe, they still can be executed from managed code using COM+. Using the N/ Direct features of C# and COM+, you can use the C language API. With the help of the COM+ run-time and the COM+ Common Language Specification (CLS), you can access the COM and COM+ API. Using the Sysimport attribute, you can even access native Windows API (DLLs) in C#. See the Attributes section of this article for more about attributes. c. Typesafety C# is a typesafe language. All variables and classes (including primitive type, such as integer, Boolean, and float) in C# are a type, and all type are derived from the object the object type. The object type provides basic functionality, such as string conversion, and information about a type. (See The Object Class section of this article for more about the object type.) C# doesn t support unsafe type assignments. In other words, assigning a float variable directly to a Boolean variable is not permitted. If you assign a float type to a Boolean type, the compiler generates an error. C# supports two kinds of type: value type and reference types. All value types are initialized with a value of zero, and all reference types are automatically initialized with a null value (local variable need to be initialized explicitly or the compiler throw a warning). The Type in C# section of this article will discuss types in more detail. d. Automatic Memory Management and Garbage Collection Automatic memory management and garbage collection are two important features of C#. With C#, you don t need to allocate memory or release it. The garbage collection feature ensures that unused references are deleted and cleaned up in memory. You use the new operator to create type object, but

3 you never need to call a delete operator to destroy the object. If the garbage collector finds any unreferenced object hanging around in memory, it removes it for you. Although you can t call delete directly on an object, you have way to get garbage collector to destroy objects. e. Versioning Control and Scalable If you re a Microsoft Window developer, you should be familiar with the expression DLL hell, which refers to having multiple versions of the same Dynamic Link Library (DLL) and not having backward and forward compatibility. For example, you can t run programs written in Microsoft Foundation class (MFC) version4.0 on systems with MFC version 3.0 or earlier. This is one of the biggest challengers for a developer, especially if you re developing MFC applications. C# model is based on namespaces. All interfaces and classes must be bundled under a namespace. A namespace has classes as its members. You can access all the members or just a single member of a namespace. Two separate namespaces can have the same class as their member.c# also supports binary compatibility with a base class. Adding a new method to a base class won t cause any problems in your existing application. The.NET assemblies contain metadata called manifest. A manifest stores information about an assembly such as its version, locale, and signature. There is no concept of registry entries for handing compatibility. In.NET, you simple put your assembly into one global folder if you want to make it sharable; otherwise, you put it in a private folder for private use only. f. Language and Cross Platform Interoperability C#, as with all Microsoft.NET supported language, shares a common.net run-time library. The language compiler generates intermediate language (IL) code, which a.net supported compiler can read with the help of the CLR. Therefore, you can use a C# assembly in VB.NET without any problem, and vice versa. With the full support of COM+ and.net framework services, C# has the ability to run on cross-platform systems. The Web-based applications created from.net use an Extensible Markup Language (XML) model, which can run on multiple platforms. g. Advanced Features introduced in C# 2.0 and 3.0 These features are discussed in more details in C# 2.0 Features and C# 3.0 Features sections of this tutorial. The following features were introduced in C# version 2.0. Partial classes Generics Nullable Types Anonymous Methods Iterators

4 Property Access Accessibility Modifiers The following features were introduced in C# version 3.0. Extension Methods Implicit Typed Local Variables Object and Collection Initializers Query Expressions Lambda Expressions What Is the.net Framework? The.NET Framework is an environment that supports the development and execution of highly distributed, component-based applications. It enables differing computer languages to work together and provides for security, program portability, and a common programming model for the Windows platform. There are two major components which makes the.net framework are CLR and class library. CLR: The first is the Common Language Runtime (CLR), which is the runtime environment of all programming languages in the framework and manages the execution of your program. Class Library: The second entity is the.net class library. This library gives your program access to the runtime environment. For example, if you want to perform I/O, such as displaying something on the screen, you will use the.net class library to do it. Architecture

5 Net Frame work.net Framework is made up of the Common Language Runtime (CLR), the Base Class Library (System Classes). This allows us to build our own services (Web Services or Windows Services) and Web Applications (Web forms Or Asp.Net), and Windows applications (Windows forms). The languages in the framework can all be used? Independently to build application and can all be used with built-in data describers (XML) and data assessors (ADO.NET and SQL). Every component of the.net Framework can take advantage of the large pre- built library of classes called the Framework Class Library (FCL). Once everything is put together, the code that is created is executed in the Common Language Runtime. Common Language Runtime is designed to allow any.net-compliant language to execute its code. At the time of writing, these languages included VB.Net, C# and C++.NET, but any language can become.net- compliant, if they follow CLS rules. The following sections will address each of the parts of the architecture..net Common Language Specifications (CLS): In an object-oriented environment, everything is considered as an object. (This point is explained in this article and the more advanced features are explained in other articles.) You create a template for an object (this is called the class file), and this class file is used to create multiple objects. TIP: Consider a Rectangle. You may want to create many Rectangle in your lifetime; but each Rectangle will have certain characteristics and certain functions. For example, each rectangle will have a specific width and color. So now, suppose your friend also wants to create a Rectangle. Why reinvent the Rectangle? You can create a common template and share it with others. They create the Rectangle based on your template. This is the heart of object-oriented programming?the template is the class file, and the Rectangle is the objects built from that class. Once you have created an object, your object needs to communicate with many other Objects. Even if it is created in another.net language doesn?t matter, because each language follows the rules of the CLS. The CLS defines the necessary things as common variable types (this is called the Common Type System CTS ), common visibility like when and where can one see these variables, common method specifications, and so on. It doesn?t have one rule which tells how C# composes its objects and another rule tells how VB.Net does the same thing. To steal a phrase, there is now?one rule to bind them all.? One thing to note here is that the CLS simply provides the bare rules. Languages can adhere to their own specification. In this case, the actual compilers do not need to be as powerful as those that support the full CLS. The Common Language Runtime (CLR): The heart of.net Framework is Common Language Runtime (CLR). All.NET-compliant languages run in a common, managed runtime execution environment. With the CLR, you can rely on code that is accessed from different languages. This is a huge benefit. One coder can write one module in C#, and another can access and use it from VB.Net. Automatic object management, the.net languages take care of memory issues automatically. These are the few listed? Benefits which you get from CLR.

6 Microsoft Intermediate Language (MSIL): So how can many different languages be brought together and executed together??microsoft Intermediate Language (MSIL) or, as it?s more commonly known, Intermediate Language (IL). In its simplest terms, IL is a programming language?if you wanted to, you could write IL directly, compile it, and run it. But why would want to write such low level code? Microsoft has provided with higher-level languages, such as C#, that one can use. Before the code is executed, the MSIL must be converted into platform-specific code. The CLR includes something called a JIT compiler in which the compiler order is as follows. Source Code => Compiler => Assembly =>Class Loader =>Jit Compiler =>Manged Native Code=>Execution. The above is the order of compilation and execution of programs. Once a program is written in a.net compliant language, the rest all is the responsibility of the frame work. Net C# Tutorial Intermediate Language - MSIL Microsoft Intermediate Language (MSIL) is a platform independent language that gets compiled into platform dependent executable file or dynamic link library. It means.net compiler can generate code written using any supported languages and finally convert it to the required machine code depending on the target machine. To get some clarity in this language we need to write some code. In this tutorial we?ll use a very simple piece of source code in C#.Net. Now we need to compile this code using csc command in Microsoft.NET on the command line. To do this, please type next string: csc ILSample.cs. After it compiler will create an executable file named ILSample.exe. After this type the command called ILDasm. It will open application called Intermediate Language Disassembler. In file menu choose open and find our executable file.this application opens our assembly showing all structural units viz., classes, methods, data fields and all global and local application data. Now if you click on the method it shows code in intermediate language. This code is most like at language with independent set of instructions. Example: public double GetVolume() double volume = height*width*thickness; if(volume<0) return 0; return volume; You can get the strings of Microsoft Intermediate Language code using ILDasm:.method public hidebysig instance float64 GetVolume() cil managed

7 // Code size 51 (0x33).maxstack 2.locals init ([0] float64 volume, [1] float64 CS$ $ ) IL_0000: ldarg.0 IL_0001: ldfld float64 OOP.Aperture::height IL_0006: ldarg.0 IL_0007: ldfld float64 OOP.Aperture::width IL_000c: mul IL_000d: ldarg.0 IL_000e: ldfld float64 OOP.Aperture::thickness IL_0013: mul IL_0014: stloc.0 IL_0015: ldloc.0 IL_0016: ldc.r8 0.0 IL_001f: bge.un.s IL_002d IL_0021: ldc.r8 0.0 IL_002a: stloc.1 IL_002b: br.s IL_0031 IL_002d: ldloc.0 IL_002e: stloc.1 IL_002f: br.s IL_0031 IL_0031: ldloc.1 IL_0032: ret // end of method Aperture::GetVolume To clearly understand that IL really is immediately language you should write the same code in VB.NET and look at these two sources in IL. These methods will be almost identical. The main advantages of IL are: 1. IL isn?t dependent on any language and there is a possibility to create applications with modules that were written using different.net compatible languages. 2. Platform independence - IL can be compiled to different platforms or operating systems. The Common Language Infrastructure (CLI) is a specification that allows several different programming languages to be used together on a given platform Parts of the Common Language Infrastructure: Common Intermediate language (CIL) including a common type system (CTS) Common Language Specification (CLS) - shared by all languages Virtual Execution System (VES) Metadata about types, dependent libraries, attributes, and more

8 The Common Language Infrastructure supports a two-step compilation process Compilation The C# compiler: Translation of C# source to CIL Produces.dll and.exe files Just in time compilation: Translation of CIL to machine code Execution With interleaved Just in Time compilation On Mono: Explicit activation of the interpreter On Window: Transparent activation of the interpreter Most simple types in C# are similar to the simple types in C Major differences: o All simple C# types have fixed bit sizes o C# has a boolean type called bool o C# chars are 16 bit long o In C# there is a high-precision 128 bit numeric fixed-point type called decimal o Pointers are not supported in the normal parts of a C# program In the unsafe part C# allows for pointers like in C All simple types are in reality structs in C#, and therefore they have members Differences with other languages C# VB C++ J-script other Compiler C++ Compiler Executable Existing OS Intermediate Language JIT Executables.NET CLR Machine hardware HOW DOES C# DIFFER FROM C++? 01. C# compiles straight from source code to executable code, with no object files. 02. C# does not separate class definition from implementation. Classes are defined and implemented in the same place and therefore there is no need for header files. 03. In C#, class definition does not use a semicolon at the end. 04. The first character of the Main ( ) function is capitalized. The Main must return either int or void

9 type value. 05. C# does not support #include statement. (Note that using is not the same as #include). 06. C# checks for uninitialized variables and gives error messages at compile time. In C++, an uninitialized variable goes undetected thus resulting in unpredictable output. 07. C# permits declaration of variables between goto and label. 08. We can only create objects in C# using the new keyword. 09. C# provides special syntax to initialize arrays efficiently. 10. C# supports four iteration statements rather than three in C++. The fourth one is the foreach statement. 11. C# does not allow silent fall-through in switch statements. It requires an explicit jump statement at the end of each case statement. 12. In C#, switch can also be used on string values. 13. C# can check overflow of arithmetic operations and conversions using checked and unchecked keywords. 14. C# does not support default arguments Variable method parameters are handled differently in C#. 16. In exception-handling, unlike in C++, we cannot throw any type in C#. The thrown value has to be a reference to a derived class or System. Exception object. 17. C# requires ordering of catch blocks correctly...! 18. C# does not provide any defaults for constructors. 19. When overriding a virtual method, we must use the override keyword. 20. Abstract methods in C# are similar to virtual functions in C++, but C# abstract Methods cannot have implementations. 21. Command-line parameters array behave differently in C# as compared to C++. HOW DOES C# DIFFER FROM JAVA? 01. Although C# uses.net runtime that is similar to Java runtime, the C# compiler produces an executable code 02. C# has more primitive.data type~. 03. Unlike Java, all C# data types are objects. 04. Arrays are declared differently in C#. 05. Although C# classes are quite similar to Java classes, there are a few important differences relating to constants, base classes and Constructors, versioning, accessibility of members etc. 06. C# supports the struct type and Java does not. 07. Java does not provide operator overloading, 08. C# provides better versioning support than java. 09. C# provides built in delegates and events. Java uses interfaces and inner classes to achieve a similar result.

10 10. In java, the switch statement can have only integer expression, while C# supports either an integer or string expression. 11. C# provides a fourth type of iteration statement, foreach for quick and easy iterations over collections and array type data. 12. C# checks overflows using checked statements. 13. C# uses is operator instead of instanceof operator in Java. 14. C# allows a variable number of parameters using the params keyword. Overview of C# A First Simple Program It is now time to look at an actual C# program. We will begin by compiling and running the short program shown here: /* This is a simple C# program. Call this program Example.cs. */ using System; class Example // A C# program begins with a call to Main(). static void Main() Console.WriteLine("A simple C# program."); Using Visual C#, there are two general approaches that you can take to creating, compiling, and running a C# program. First, you can use the Visual Studio IDE. Second, you can use the command-line compiler, csc.exe. Both methods are described here. Using csc.exe, the C# Command-Line Compiler Although the Visual Studio IDE is what you will probably be using for your commercial projects, some readers will find the C# command-line compiler more convenient, especially for compiling and running the sample programs shown in this book. The reason is that you don t have to create a project for the program. You can simply create the program and then compile it and run it all from the command line. Therefore, if you know how to use the Command Prompt window and its command-line interface, using the command-line compiler will be faster and easier than using the IDE. To create and run programs using the C# command-line compiler, follow these three steps: 1. Enter the program using a text editor.

11 2. Compile the program using csc.exe. 3. Run the program. 1. Entering the Program Enter the program into your computer using a text editor, such as Notepad. Remember, you must create text-only files, not formatted word-processor files, because the format information in a word processor file will confuse the C# compiler. When entering the program, call the file Example.cs. 2. Compiling the Program To compile the program, execute the C# compiler, csc.exe, specifying the name of the source file on the command line, as shown here: C:\>csc Example.cs The csc compiler creates a file called Example.exe that contains the MSIL version of the program. Although MSIL is not executable code, it is still contained in an exe file. The Common Language Runtime automatically invokes the JIT compiler when you attempt to execute Example.exe. Be aware, however, that if you try to execute Example.exe (or any other exe file that contains MSIL) on a computer for which the.net Framework is not installed, the program will not execute because the CLR will be missing. 3. Running the Program To actually run the program, just type its name on the command line, as shown here: C:\>Example When the program is run, the following output is displayed: A simple C# program. Using the Visual Studio IDE Visual Studio is Microsoft s integrated programming environment. It lets you edit, compile, run, and debug a C# program, all without leaving its well-thought-out environment. Visual Studio offers convenience and helps manage your programs. The steps required to edit, compile, and run a C# program using the Visual Studio 2008 IDE are shown here. These steps assume the IDE provided by Visual C # 2008 Express Editions. Slight differences may exist with other versions of Visual Studio Create a new, empty C# project by selecting File New Project. Next, select EmptyvProject:

12 Then, press OK to create the project. 2. Once the new project is created, the Visual Studio IDE will look like this If for some reason you do not see the Solution Explorer window, activate it by selecting Solution Explorer from the View menu. 3. At this point, the project is empty and you will need to add a C# source file to it. Do this by rightclicking on Project1 in the Solution Explorer and then selecting Add.You will see the following

13 4. Next, select New Item. This causes the Add New Item dialog to be displayed. Select Code File and then change the name to Example.cs, as shown here: 5. Next, type the example program into the Example.cs window and then save the file. 6. Compile the program by selecting Build Solution from the Build menu. 7. Run the program by selecting Start Without Debugging from the Debug menu. The First Sample Program, Line by Line Although Example.cs is quite short, it includes several key features that are common to all C# programs. Let s closely examine each part of the program, beginning with its name. The name of a C# program is arbitrary. Unlike some computer languages (most notably, Java) in which the name of a program file is very important, this is not the case for C#. You were told to call the sample program Example.cs so that the instructions for compiling and running the program would apply, but as far as C# is concerned, you could have called the file by another name. For example, the preceding sample program could have been called Sample.cs, Test.cs, or even X.cs. By convention, C# programs use the.cs file extension, and this is a convention that you should follow. Also, many programmers call a file by the name of the principal class defined within the file. This is why the filename Example.cs was chosen. Since the names of C# programs are arbitrary, names won t be specified for most of the sample programs in this book. Just use names of your own choosing. The program begins with the following lines: /* This is a simple C# program. Call this program Example.cs. */ This is a comment. Like most other programming languages, C# lets you enter a remark into a program s source file. The contents of a comment are ignored by the compiler. Instead, a comment describes or explains the operation of the program to anyone who is reading its source code. In this case, the comment describes the program and reminds you to call the source file Example.cs. Of course, in real applications, comments generally explain how some part of the program works or what a specific feature does.

14 C# supports three styles of comments. The one shown at the top of the program is called a multiline comment. This type of comment must begin with /* and end with */. Anything between these two comment symbols is ignored by the compiler. As the name suggests, a multiline comment can be several lines long. The next line in the program is using System; This line indicates that the program is using the System namespace. In C#, a namespace defines a declarative region. Through the use of namespaces, it is possible to keep one set of names separate from another. In essence, names declared in one namespace will not conflict with names declared in a different namespace. The namespace used by the program is System, which is the namespace reserved for items associated with the.net Framework class library, which is the library used by C#. The using keyword simply states that the program is using the names in the given namespace. The next line of code in the program is shown here: class Example This line uses the keyword class to declare that a new class is being defined. As mentioned, the class is C# s basic unit of encapsulation. Example is the name of the class. The class definition begins with the opening curly brace () and ends with the closing curly brace (). The elements between the two braces are members of the class. For the moment, don t worry too much about the details of a class except to note that in C#, most program activity occurs within one. The next line in the program is the single-line comment, shown here: // A C# program begins with a call to Main(). This is the second type of comment supported by C#. A single-line comment begins with a // and ends at the end of the line. Although styles vary, it is not uncommon for programmers to use multiline comments for longer remarks and single-line comments for brief, line-byline descriptions. (The third type of comment supported by C# aids in the creation of documentation and is described in Appendix A.) The next line of code is shown here: static void Main() This line begins the Main( ) method. As mentioned earlier, in C#, a subroutine is called a method. As the comment preceding it suggests, this is the line at which the program will begin executing. All C# applications begin execution by calling Main( ). The complete meaning of each part of this line cannot be given now, since it involves a detailed understanding of several other C# features. However, since many of the examples in this book will use this line of code, we will take a brief look at it here. The line begins with the keyword static. A method that is modified by static can be called before an object of its class has been created. This is necessary because Main( ) is called at program startup. The keyword void indicates that Main( ) does not return a value. As you will see, methods can also return values. The empty parentheses that follow Main indicate that no information is passed to Main( ). Although it is possible to pass information into Main( ), none is passed in this example. The last character on the line is the. This signals the start of Main( ) s body. All of the code that comprises a method will occur between the method s opening curly brace and its closing curly brace.

15 The next line of code is shown here. Notice that it occurs inside Main( ). Console.WriteLine("A simple C# program."); This line outputs the string A simple C# program. followed by a new line on the screen. Output is actually accomplished by the built-in method WriteLine( ). In this case, WriteLine( ) displays the string that is passed to it. Information that is passed to a method is called an argument. In addition to strings, WriteLine( ) can be used to display other types of information. The line begins with Console, which is the name of a predefined class that supports console I/O. By connecting Console with WriteLine( ), you are telling the compiler that WriteLine( ) is a member of the Console class. The fact that C# uses an object to define console output is further evidence of its object-oriented nature. Notice that the WriteLine( ) statement ends with a semicolon, as does the using System statement earlier in the program. In general, statements in C# end with a semicolon. The exception to this rule are blocks, which begin with a and end with a. This is why those lines in the program don t end with a semicolon. Blocks provide a mechanism for grouping statements and are discussed later in this chapter. The first in the program ends Main( ), and the last ends the Example class definition. One last point: C# is case-sensitive. Forgetting this can cause serious problems. For example, if you accidentally type main instead of Main, or writeline instead of WriteLine, the preceding program will be incorrect. Furthermore, although the C# compiler will compile classes that do not contain a Main( ) method, it has no way to execute them. So, had you mistyped Main, you would see an error message that states that Example.exe does not have an entry point defined. A Small Variation Although all of the programs in this book will use it, the line using System; at the start of the first example program is not technically needed. It is, however, a valuable convenience. The reason it s not necessary is that in C# you can always fully qualify a name with the namespace to which it belongs. For example, the line Console.WriteLine("A simple C# program."); can be rewritten as System.Console.WriteLine("A simple C# program."); Thus, the first example could be recoded as shown here: // This version does not include "using System;". class Example // A C# program begins with a call to Main(). static void Main() // Here, Console.WriteLine is fully qualified. System.Console.WriteLine("A simple C# program.");

16 Since it is quite tedious to always specify the System namespace whenever a member of that namespace is used, most C# programmers include using System at the top of their programs, as will all of the programs in this book. It is important to understand, however, that you can explicitly qualify a name with its namespace if needed. Multiple main method support The designers of C# included a mechanism by which you can define more than one class with a Main method. Why would you want to do that? One reason is to place test code in your classes. You can then use the /main:< classname > switch with the C# compiler to specify which class's Main method is to be used. Here's an example in which I have two classes containing Main methods: - using System; class Main1 public static void Main() Console.WriteLine("Main1"); class Main2 public static void Main() Console.WriteLine("Main2"); To compile this application such that the Main1.Main method is used as the application's entry point, you'd use this switch: - csc MultipleMain.cs /main:main1 Changing the switch to /main:main2 would then use the Main2.Main method. Obviously, because C# is case-sensitive, you must be careful to use the correct case of the class in the switch as well. In addition, attempting to compile an application consisting of multiple classes with defined Main methods and not specifying the /main switch will result in a compiler error. Summary The above chapter provides the overview and brief introduction about the.net Platform and the C3 language introduction to the programming world. The objective of the framework is providing the language compatibility i.e. code s written in different languages can communicate through a single platform. It also describes the Runtime engine of.net framework, which includes the CLR.CLS and CTS.

17 Key terms: Framework, CLR, CLS, CTS, Namespace, Assembly, Versioning, Manage module, IL code, MSIL Manifests. Key term Quiz: 1., on the other hand is code run outside the CLR 2. The.NET assemblies contain metadata called 3. is an environment that supports the development and execution of highly distributed, component-based applications 4..NET-compliant languages run in a common, managed runtime execution environment known as 5. All types are initialized with a value of zero, and all types are automatically initialized with a null value Objective Questions 1. C# (C-Sharp) was developed by a) Sun Microsystems b) Microsoft c) Intel d) IBM 2. What is C# (C-Sharp)? a) An Operating System b) An Programming Tool c) An Programming Language d) None of these 3. C# (C-Sharp) belongs to which framework? a) Java b).net c) It doesn t belong to any framework d) None of these 4. What is CLR? a) Conventional Language Runtime b) Clarified Language Runtime c) Common Language Runtime d) Colloquial Language Runtime 5. Object Oriented Programming (OOP) is a style of programming in which your code is broken up into units, known as a) Objects b) classes c) objects or classes d) objects and classes 6. There are, however, some advanced features of C++, such as that are not supported in.net, and are therefore, not available in managed code. a) Templates b) Runtime classes c) base classes d) multiple-document-interfaces 7. Using C# you can, for example, write a web page a) Dynamic b) static c) standard d) classical 8. Using C# you can, for example, write of a distributed application a) a core b) a component c) an array d) a structure 9. This is because they all have the same familiar Windows at their core. a) GUID b) IDE c) DLL d) API 10. What is OLE? a) Object Linking and Embedding b) Oriented Linking and Embedding c) Object Location and Embedding c) Objective Location and Embedding

18 11. What actually manages your code? a) JIT b) CTS c) CLR d) CLS 12. When the. NET runtime loads and runs code, this is the language that it expects to find the code in. a) Intermediate Language b) Common Type System c) Just-in-Time Compilation d) Globally Unique IDentifiers 13. When you compile managed code, the actually emits IL. a) Debugger b) collector c) translator d) compiler 14. this is a minimum set of standards that guarantees that code can be accessed from any language. a) Common Type System b) Common Language Specification c) Just-in-Time Compilation d) The.NET Runtime 15. Common Language Specification: This is a minimum set of standards that guarantees that code can be accessed from any a)compiler b) stage c) application d)language Types in C# C# Value Types and Reference Types C# permits the use of value types, such as enumerations and structures, and reference types, such as objects instantiated from classes. Value types hold their data directly and can be easily copied. Reference types add a layer of indirection. Value Types Value types include the integral numeric data types such as "int", other structures and enumerations. When a value type is assigned to a variable, the variable contains that information directly. If a second variable is assigned the value of the first, a copy of the contents is made. The two copies can then be used independently. This is analogous to the ing of files as attachments. A user may have a word-processed document that another user wishes to edit. This document can be ed to the second user as an attachment. Either user can now modify the document in any way without affecting the other's copy. To illustrate what happens when value type a variable is copied, consider the following diagram. In the first step, the variable "a" is declared and assigned a value of 72. You can see this value becoming the contents of the variable in the first column.

19 In the second step, the variable "b" is declared and assigned the value from variable "a". This value is copied into the contents of the new variable, as can be seen in the second column. In the third step, the value in variable "a" is modified. The value in variable "b" is unchanged because this variable contains an independent copy of the value. The two variables are not linked in any way. Reference Types Reference types include classes of objects. When a reference type is assigned to a variable, the variable does not contain the contents of the object directly. Instead, the object's data is constructed in memory and the variable contains a reference to that memory location. If a second variable is assigned the value of the first, a copy of the reference is made. The two variables now contain independent copies of the reference but in each case the reference points to the same data. If the properties of such an object are changed, the change is apparent through both references. To illustrate what happens when reference type a variable is copied, consider the following diagram. In the first step, the object "a" is declared as an instance of the Person class. This is a simple class with a single property representing the person's height in inches. A new area in memory, represented by the "X" column, is allocated to hold the object's contents. Currently the contents are null because the property has not been set. The variable "a" holds a reference to the memory location "X". In the second step, the Height property of variable "a" is set to 72. The contents of the first column are unmodified because the reference itself has not changed. However, the memory location holding the height property is changed as can be seen in the third column. In the third step, a second Person variable "p" is declared and assigned the value of variable "a". As these are reference types, the reference to the "X" memory location is copied into variable "b". Both variables have a reference to the same underlying location and both now return a Height property of 72. In the final step, the Height property of variable "a" is changed to 75. This does not modify the reference within the variable, only the contents of the memory holding the property, seen in the "X" column. As both variables still reference that memory location, both variables will return a Height property of 75.

20 Variables and Types "Variables" are simply storage locations for data. You can place data into them and retrieve their contents as part of a C# expression. The interpretation of the data in a variable is controlled through "Types". C# is a "Strongly Typed" language. Thus all operations on variables are performed with consideration of what the variable's "Type" is. There are rules that define what operations are legal in order to maintain the integrity of the data you put in a variable. The C# simple types consist of the Boolean type and three numeric types - Integrals, Floating Point, Decimal, and String. The term "Integrals", which is defined in the C# Programming Language Specification, refers to the classification of types that include sbyte, byte, short, ushort, int, uint, long, ulong, and char. More details are available in the Integral Types section later in this lesson. The term "Floating Point" refers to the float and double types, which are discussed, along with the decimal type, in more detail in the Floating Point and Decimal Types section later in this lesson. The string type represents a string of characters and is discussed in The String Type section, later in this lesson. The next section introduces the boolean type. The Boolean Type Boolean types are declared using the keyword, bool. They have two values: true or false. In other languages, such as C and C++, boolean conditions can be satisfied where 0 means false and anything else means true. However, in C# the only values that satisfy a boolean condition is true and false, which are official keywords. Displaying Boolean Values: Boolean.cs using System; class Booleans public static void Main() bool content = true; bool nocontent = false; Console.WriteLine("It is 0 that C# Station provides C# programming language content.", content); Console.WriteLine("The statement above is not 0.", nocontent);

21 the boolean values are written to the console as a part of a sentence. The only legal values for the bool type are either true or false, as shown by the assignment of true to content and false to nocontent. When run, this program produces the following output: It is True that C# Station provides C# programming language content.the statement above is not False. Integral Types In C#, an integral is a category of types. For anyone confused because the word Integral sounds like a mathematical term, from the perspective of C# programming, these are actually defined as Integral types in the C# programming language specification. They are whole numbers, either signed or unsigned, and the char type. The char type is a Unicode character, as defined by the Unicode Standard.. table 2-1 shows the integral types, their size, and range. Type Size (in bits) Range sbyte to 127 byte 8 0 to 255 short to ushort 16 0 to int to uint 32 0 to long to ulong 64 0 to char 16 0 to Table. The Size and Range of C# Integral Types Integral types are well suited for those operations involving whole number calculations. The char type is the exception, representing a single Unicode character. As you can see from the table above, you have a wide range of options to choose from, depending on your requirements. Floating Point and Decimal Types A C# floating point type is either a float or double. They are used any time you need to represent a real number, as defined by IEEE 754. For more information on IEEE 754, visit the IEEE Web Site. Decimal types should be used when representing financial or money values. table 2-2 shows the floating point and decimal types, their size, precision, and range. Type Size (in bits) precision Range float 32 7 digits 1.5 x to 3.4 x 10 38

22 double digits 5.0 x to 1.7 x decimal decimal places 1.0 x to 7.9 x The Floating Point and Decimal Types with Size, precision, and Range Floating point types are used when you need to perform operations requiring fractional representations. However, for financial calculations, the decimal type is the best choice because you can avoid rounding errors. The string Type A string is a sequence of text characters. You typically create a string with a string literal, enclosed in quotes: "This is an example of a string." You've seen strings being used in Lesson 1, where we used the Console.WriteLine method to send output to the console. Some characters aren't printable, but you still need to use them in strings. Therefore, C# has a special syntax where characters can be escaped to represent non-printable characters. For example, it is common to use newlines in text, which is represented by the '\n' char. The backslash, '\', represents the escape. When preceded by the escape character, the 'n' is no longer interpreted as an alphabetical character, but now represents a newline. You may be now wondering how you could represent a backslash character in your code. We have to escape that too by typing two backslashes, as in '\\'. table 2-3 shows a list of common escape sequences. Table 2-3. C# Character Escape Sequences Escape Sequence Meaning \' Single Quote \" Double Quote \\ Backslash \0 Null, not the same as the C# null value \a Bell \b Backspace \f form Feed \n Newline \r Carriage Return \t Horizontal Tab \v Vertical Tab

23 Another useful feature of C# strings is the verbatim literal, which is a string with symbol prefix, as string". Verbatim literals make escape sequences translate as normal characters to enhance readability. To appreciate the value of verbatim literals, consider a path statement such as "c:\\topdir\\subdir\\subdir\\myapp.exe". As you can see, the backslashes are escaped, causing the string to be less readable. You can improve the string with a verbatim literal, like That is fine, but now you have the problem where quoting text is not as easy. In that case, you would specify double double quotes. For example, the string "copy \"c:\\source file name with spaces.txt\" c:\\newfilename.txt" would be written as the verbatim ""c:\source file name with spaces.txt"" c:\newfilename.txt". Basic String Operators Concatenation Operator The string data type does not contain any numeric value and therefore cannot be used in arithmetic operations. However, the addition operator (+) is available for string operations. This can be used to concatenate two strings into one longer string. string start = "This is a "; string end = "concatenated string!"; string concat = start + end; // concat = "This is a concatenated string!" The concatenation operator, like the addition operation, can be used as a compound assignment operator with the addition of an equals sign (+=). string start = "This is a "; string end = "concatenated string!"; start += end; // start = "This is a concatenated string!" Relational Operators The string data type supports the use of just two relational operators. These are for equality (==) and inequality (!=) testing. The remainder of the relational operators are unavailable as they may only be used on data types that support the concept of ordering. It is important to note that the relational operators perform comparisons that are case-sensitive as shown in the following examples: string s1 = "String to compare."; string s2 = "String to compare."; string s3 = "String to Compare."; // Note the capital "C" bool result; result = s1 == s2; // result = true result = s1 == s3; // result = false result = s1!= s2; // result = false result = s1!= s3; // result = true

24 Null Coalescing Operator In the previous part of the tutorial we introduced the string data type as a class and explained that all strings are actually objects. It was also noted that all objects are nullable. This means that the null coalescing operator (??) can be used with strings when developing under.net framework 2.0. string notnullstring = "A string"; string nullstring = null; string nullteststring; nullteststring = notnullstring?? "Null"; // nullteststring = "A string" nullteststring = nullstring?? "Null"; // nullteststring = "Null" The null coalescing operator is not available in earlier versions of the.net framework. If you are developing in version 1.1 or earlier, the same functionality can be provided using the conditional and equality operators. string notnullstring = "A string"; string nullstring = null; string nullteststring; // Mimic the functionality of the null coalescing operator nullteststring = notnullstring == null? "Null" : notnullstring; // "A string" nullteststring = nullstring == null? "Null" : nullstring; // "Null" C# Operators Results are computed by building expressions. These expressions are built by combining variables and operators together into statements. The following table describes the allowable operators, their precedence, and associativity. Table 2-4. Operators with their precedence and Associativity Category (precedence) Operator(s) Associativity Primary x.y f(x) a[x] x++ x-- new typeof default checked unchecked delegate left Unary + -! ~ ++x --x (T)x left Multiplicative * / % left Additive + - left Shift << >> left Relational < > <= >= is as left Equality ==!= right

25 Logical AND & left Logical XOR ^ left Logical OR left Conditional AND && left Conditional OR left Null Coalescing?? left Ternary?: right Assignment = *= /= %= += -= <<= >>= &= ^= = => right Left associativity means that operations are evaluated from left to right. Right associativity mean all operations occur from right to left, such as assignment operators where everything to the right is evaluated before the result is placed into the variable on the left. Most operators are either unary or binary. Unary operators form expressions on a single variable, but binary operators form expressions with two variables.in addition to unary operators, C# has binary operators that form expressions of two variables. Summary A variable is an identifier with a type that holds a value of that type. Simple types include the integrals, floating points, decimal, and bool. C# has several mathematical and logical operators that participate in forming expressions. C# also offers the single dimension, multi-dimension and jagged array types. In this lesson you learned how to write simple statements and code a program that works linearly from start to finish. However, this is not as useful as it can be because you need to be able to make decisions and execute different blocks of code depending on different conditions. Control structures in C# Branching IF Statement An if statement allows you to take different paths of logic, depending on a given condition. When the condition evaluates to a boolean true, a block of code for that true condition will execute. You have the option of a single if statement, multiple else if statements, and an optional else statement. Listing below shows how each of these types of if statements work. These structures are as follows: if (expression) statement1...[n] elseif (expression) statement1...[n]

26 . else statement1...[n] Please pay attention to logical operators && and while using then as a expression in if structure because as we explain earlier they won't check the second operand if the first one fulfill the condition You must begin with the keyword if. Next is the boolean expression between parenthesis. This boolean expression must evaluate to a true or false value. In this case, we are checking the user's input to see if it is greater than (>) 0. If this expression evaluates to true, we execute the statements within the curly braces. (We refer to the structure with curly braces as a "block") There could be one or more statements within this block. If the boolean expression evaluates to false, we ignore the statements inside the block and continue program execution with the next statement after the block. Note: In other languages, such as C and C++, conditions can be evaluated where a result of 0 is false and any other number is true. In C#, the condition must evaluate to a boolean value of either true or false. If you need to simulate a numeric condition with C#, you can do so by writing it as (myint!= 0), which means that the expression evaluate to true if myint is not 0. Switch Another form of selection statement is the switch statement, which executes a set of logic depending on the value of a given parameter. The types of the values a switch statement operates on can be booleans, enums, integral types, and strings. switch (expression) case constant-expression: statement jump-statement case constant-expressionn: statementn [default] The switch statement begins with the switch keyword followed by the switch expression. In the first switch statement in listing 3-2, the switch expression evaluates to an int type, as follows: // switch with integer type switch (myint) case 1:

27 Console.WriteLine("Your number is 0.", myint); break; case 2: Console.WriteLine("Your number is 0.", myint); break; default: Console.WriteLine("Your number 0 is not between 1 and 3.", myint); break; The switch block follows the switch expression, where one or more choices are evaluated for a possible match with the switch expression. Each choice is labeled with the case keyword, followed by an example that is of the same type as the switch expression and followed by a colon (:). In the example we have case 1:, case 2:, and case 3:. When the result evaluated in the switch expression matches one of these choices, the statements immediately following the matching choice are executed, up to and including a branching statement, which could be either a break, continue, goto, return, or throw statement. table summarizes the branching statements. Table. C# Branching Statements Branching statement Break Continue Goto return throw Description Leaves the switch block Leaves the switch block, skips remaining logic in enclosing loop, and goes back to loop condition to determine if loop should be executed again from the beginning. Leaves the switch block and jumps directly to a label of the form "<labelname>:" Leaves the current method. Throws an exception. You may also include a default choice following all other choices. If none of the other choices match, then the default choice is taken and its statements are executed. Although use of the default label is optional, I highly recommend that you always include it. This will help catch unforeseen circumstances and make your programs more reliable. Each case label must end with a branching statement, as described in table, which is normally the break statement. The break statement will cause the program to exit the switch statement and begin execution with the next statement after the switch block. There are two exceptions to this: adjacent case statements with no code in between or using a goto statement. Here's an example that shows how to combine case statements:

28 switch (myint) case 1: case 2: case 3: Console.WriteLine("Your number is 0.", myint); break; default: Console.WriteLine("Your number 0 is not between 1 and 3.", myint); break; By placing case statements together, with no code in-between, you create a single case for multiple values. A case without any code will automatically fall through to the next case. The example above shows how the three cases for myint equal to 1, 2, or 3, where case 1 and case 2 will fall through and execute code for case 3. A case statement can only be an exact match and you can't use logical conditions. If you need to use logical conditions, you can use an if/else if/else statement. Another way to control the flow of logic in a switch statement is by using the goto statement. You can either jump to another case statement, or jump out of the switch statement. The second switch statement in Listing 3-2 shows the use of the goto statement, as shown below: // switch with string type switch (myinput) case "continue": goto begin; case "quit": Console.WriteLine("Bye."); break; default: Console.WriteLine("Your input 0 is incorrect.", myinput); goto decide; Note: in the current example, "continue", is a case of the switch statement -- not the keyword. The while Loop A while loop will check a condition and then continues to execute a block of code as long as the condition evaluates to a boolean value of true. Its syntax is as follows: while (<boolean expression>) <statements>. The statements can be any valid C# statements. The boolean expression is evaluated

29 before any code in the following block has executed. When the boolean expression evaluates to true, the statements will execute. Once the statements have executed, control returns to the beginning of the while loop to check the boolean expression again. while (expression) statement1...[n] When the boolean expression evaluates to false, the while loop statements are skipped and execution begins after the closing brace of that block of code. Before entering the loop, ensure that variables evaluated in the loop condition are set to an initial state. During execution, make sure you update variables associated with the boolean expression so that the loop will end when you want it to. Listing shows how to implement a while loop. Example The While Loop: WhileLoop.cs using System; class WhileLoop public static void Main() int myint = 0; while (myint < 10) Console.Write("0 ", myint); myint++; Console.WriteLine(); The do Loop do statement1...[n] while (expression); In comparison between while and do while, do while will execute the statement at least once. A do loop is similar to the while loop, except that it checks its condition at the end of the loop. This means that the do loop is guaranteed to execute at least one time. On the other hand, a while loop evaluates its boolean expression at the beginning and there is generally no guarantee that the statements inside the loop will be executed, unless you program the code to explicitly do so.

30 The for Loop A for loop works like a while loop, except that the syntax of the for loop includes initialization and condition modification. for loops are appropriate when you know exactly how many times you want to perform the statements within the loop. The contents within the for loop parentheses hold three sections separated by semicolons (<initializer list>; <boolean expression>; <iterator list>) <statements>. The initializer list is a comma separated list of expressions. These expressions are evaluated only once during the lifetime of the for loop. This is a one-time operation, before loop execution. This section is commonly used to initialize an integer to be used as a counter. Once the initializer list has been evaluated, the for loop gives control to its second section, the boolean expression. There is only one boolean expression, but it can be as complicated as you like as long as the result evaluates to true or false. The boolean expression is commonly used to verify the status of a counter variable. When the boolean expression evaluates to true, the statements within the curly braces of the for loop are executed. After executing for loop statements, control moves to the top of loop and executes the iterator list, which is normally used to increment or decrement a counter. The iterator list can contain a comma separated list of statements, but is generally only one statement. Listing shows how to implement a for loop. The purpose of the program is to print only odd numbers less than 10. Example. The For Loop: ForLoop.cs using System; class ForLoop public static void Main() for (int i=0; i < 20; i++) if (i == 10) break; if (i % 2 == 0) continue; Console.Write("0 ", i); Console.WriteLine();

31 Normally, for loop statements execute from the opening curly brace to the closing curly brace without interruption. There are a couple if statements disrupting the flow of control within the for block. The foreach Loop foreach (collectiondatatype varname in collectionname) statement1 [n]; A foreach loop is used to iterate through the items in a list. It operates on arrays or collections such as ArrayList, which can be found in the System.Collections namespace. The syntax of a foreach loop is foreach (<type> <iteration variable> in <list>) <statements> The type is the type of item contained in the list. For example, if the type of the list was int[] then the type would be int. The iteration variable is an identifier that you choose, which could be anything but should be meaningful. For example, if the list contained an array of people's ages, then a meaningful name for item name would be age. The in keyword is required. While iterating through the items of a list with a foreach loop, the list is read-only. This means that you can't modify the iteration variable within a foreach loop. There is a subtlety here; Later, you'll learn how to create custom types, called class and struct, that can contain multiple fields. You can change the fields of the class or struct, but not the iteration variable for the class or struct itself in a foreach loop. On each iteration through a foreach loop the list is queried for a new value. As long as the list can return a value, this value will be put into the read-only iteration variable, causing the statements in the foreachblock to be executed. When the collection has been fully traversed, control will transfer to the first executable statement following the end of the foreach block. Listing demonstrates how to use a foreachloop. Example. The ForEach Loop: ForEachLoop.cs using System; class ForEachLoop public static void Main() string[] names = "Cheryl", "Joe", "Matt", "Robert"; foreach (string person in names) Console.WriteLine("0 ", person);

32 Break and Continue It's time now to talk about break and continue. Remember that, these two statements are using in loop structures. Like for, while, do while and. Let's see the usage of them in an example. If you run the following code snippet you will see that when i =5 the code will stop. It means although i is less that 100 but the rest of code won't execute. for (int i = 1; i < 100; i++) if (i%5 == 0) Console.WriteLine("Hope!"); break ; Console.WriteLine(i); The result will be as follow Figure 4 But if you change the code like this: for (int i = 1; i < 100; i++) if (i%5 == 0) Console.Write Line("Hope!"); continue ; Console.WriteLine(i); Instead of each number that is dividable to 5 the word "Hope" will be printed. The result of running the above code snippet is shown in figure 5 Figure 5 Note: You are not allowed to change the value of the counter in the foreach control structure. This is a read only value. It means you can not change the value of i in the code above.

C#: framework overview and in-the-small features

C#: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer C#: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

Introduce C# as Object Oriented programming language. Explain, tokens,

Introduce C# as Object Oriented programming language. Explain, tokens, Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

.Net Technologies. Components of.net Framework

.Net Technologies. Components of.net Framework .Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.

More information

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations , 1 C#.Net VT 2009 Course Contents C# 6 hp approx. BizTalk 1,5 hp approx. No exam, but laborations Course contents Architecture Visual Studio Syntax Classes Forms Class Libraries Inheritance Other C# essentials

More information

Introduction to C# Applications

Introduction to C# Applications 1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

New programming language introduced by Microsoft contained in its.net technology Uses many of the best features of C++, Java, Visual Basic, and other

New programming language introduced by Microsoft contained in its.net technology Uses many of the best features of C++, Java, Visual Basic, and other C#.NET? New programming language introduced by Microsoft contained in its.net technology Uses many of the best features of C++, Java, Visual Basic, and other OO languages. Small learning curve from either

More information

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class. 1. What is C#? C# (pronounced "C sharp") is a simple, modern, object oriented, and type safe programming language. It will immediately be familiar to C and C++ programmers. C# combines the high productivity

More information

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program

More information

COPYRIGHTED MATERIAL. Part I The C# Ecosystem. ChapTEr 1: The C# Environment. ChapTEr 2: Writing a First Program

COPYRIGHTED MATERIAL. Part I The C# Ecosystem. ChapTEr 1: The C# Environment. ChapTEr 2: Writing a First Program Part I The C# Ecosystem ChapTEr 1: The C# Environment ChapTEr 2: Writing a First Program ChapTEr 3: Program and Code File Structure COPYRIGHTED MATERIAL 1The C# Environment What s in This ChapTEr IL and

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

Table of Contents Preface Bare Necessities... 17

Table of Contents Preface Bare Necessities... 17 Table of Contents Preface... 13 What this book is about?... 13 Who is this book for?... 14 What to read next?... 14 Personages... 14 Style conventions... 15 More information... 15 Bare Necessities... 17

More information

Getting started 7. Storing values 21. Creating variables 22 Reading input 24 Employing arrays 26 Casting data types 28 Fixing constants 30 Summary 32

Getting started 7. Storing values 21. Creating variables 22 Reading input 24 Employing arrays 26 Casting data types 28 Fixing constants 30 Summary 32 Contents 1 2 3 Contents Getting started 7 Introducing C# 8 Installing Visual Studio 10 Exploring the IDE 12 Starting a Console project 14 Writing your first program 16 Following the rules 18 Summary 20

More information

Darshan Institute of Engineering & Technology for Diploma Studies

Darshan Institute of Engineering & Technology for Diploma Studies Overview of Microsoft.Net Framework: The Dot Net or.net is a technology that is an outcome of Microsoft s new strategy to develop window based robust applications and rich web applications and to keep

More information

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

UNIT I An overview of Programming models Programmers Perspective

UNIT I An overview of Programming models Programmers Perspective UNIT I An overview of Programming models Programmers Perspective 1. C/Win32 API Programmer It is complex C is short/abrupt language Manual Memory Management, Ugly Pointer arithmetic, ugly syntactic constructs

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Appendix G: Writing Managed C++ Code for the.net Framework

Appendix G: Writing Managed C++ Code for the.net Framework Appendix G: Writing Managed C++ Code for the.net Framework What Is.NET?.NET is a powerful object-oriented computing platform designed by Microsoft. In addition to providing traditional software development

More information

Programming in Visual Basic with Microsoft Visual Studio 2010

Programming in Visual Basic with Microsoft Visual Studio 2010 Programming in Visual Basic with Microsoft Visual Studio 2010 Course 10550; 5 Days, Instructor-led Course Description This course teaches you Visual Basic language syntax, program structure, and implementation

More information

Fundamental C# Programming

Fundamental C# Programming Part 1 Fundamental C# Programming In this section you will find: Chapter 1: Introduction to C# Chapter 2: Basic C# Programming Chapter 3: Expressions and Operators Chapter 4: Decisions, Loops, and Preprocessor

More information

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given MUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala faisalgrw123@gmail.com MEGA File Solved MCQ s For Final TERM EXAMS CS508- Modern Programming Languages Question No: 1 ( Marks: 1 ) -

More information

This tutorial has been prepared for the beginners to help them understand basics of c# Programming.

This tutorial has been prepared for the beginners to help them understand basics of c# Programming. About thetutorial C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its.net initiative led by Anders Hejlsberg. This tutorial covers basic C# programming

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Introduction To C#.NET

Introduction To C#.NET Introduction To C#.NET Microsoft.Net was formerly known as Next Generation Windows Services(NGWS).It is a completely new platform for developing the next generation of windows/web applications. However

More information

C# Programming in the.net Framework

C# Programming in the.net Framework 50150B - Version: 2.1 04 May 2018 C# Programming in the.net Framework C# Programming in the.net Framework 50150B - Version: 2.1 6 days Course Description: This six-day instructor-led course provides students

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

UNIT 1. Introduction to Microsoft.NET framework and Basics of VB.Net

UNIT 1. Introduction to Microsoft.NET framework and Basics of VB.Net UNIT 1 Introduction to Microsoft.NET framework and Basics of VB.Net 1 SYLLABUS 1.1 Overview of Microsoft.NET Framework 1.2 The.NET Framework components 1.3 The Common Language Runtime (CLR) Environment

More information

Program Fundamentals

Program Fundamentals Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java

More information

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led CENTER OF KNOWLEDGE, PATH TO SUCCESS Website: PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO 2010 Course: 10550A; Duration: 5 Days; Instructor-led WHAT YOU WILL LEARN This course teaches you

More information

2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction

2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction 1. Which language is not a true object-oriented programming language? A. VB 6 B. VB.NET C. JAVA D. C++ 2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a)

More information

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

Chapter 12 Microsoft Assemblies. Software Architecture Microsoft Assemblies 1

Chapter 12 Microsoft Assemblies. Software Architecture Microsoft Assemblies 1 Chapter 12 Microsoft Assemblies 1 Process Phases Discussed in This Chapter Requirements Analysis Design Framework Architecture Detailed Design Key: x = main emphasis x = secondary emphasis Implementation

More information

A Comparison of Visual Basic.NET and C#

A Comparison of Visual Basic.NET and C# Appendix B A Comparison of Visual Basic.NET and C# A NUMBER OF LANGUAGES work with the.net Framework. Microsoft is releasing the following four languages with its Visual Studio.NET product: C#, Visual

More information

JScript Reference. Contents

JScript Reference. Contents JScript Reference Contents Exploring the JScript Language JScript Example Altium Designer and Borland Delphi Run Time Libraries Server Processes JScript Source Files PRJSCR, JS and DFM files About JScript

More information

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017 C++\CLI Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017 Comparison of Object Models Standard C++ Object Model All objects share a rich memory model: Static, stack, and heap Rich object life-time

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

2 rd class Department of Programming. OOP with Java Programming

2 rd class Department of Programming. OOP with Java Programming 1. Structured Programming and Object-Oriented Programming During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach

More information

Full file at

Full file at Java Programming, Fifth Edition 2-1 Chapter 2 Using Data within a Program At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional

More information

Chapter 2: Using Data

Chapter 2: Using Data Chapter 2: Using Data Declaring Variables Constant Cannot be changed after a program is compiled Variable A named location in computer memory that can hold different values at different points in time

More information

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics Java Programming, Sixth Edition 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional

More information

CS112 Lecture: Working with Numbers

CS112 Lecture: Working with Numbers CS112 Lecture: Working with Numbers Last revised January 30, 2008 Objectives: 1. To introduce arithmetic operators and expressions 2. To expand on accessor methods 3. To expand on variables, declarations

More information

Basic Types, Variables, Literals, Constants

Basic Types, Variables, Literals, Constants Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic

More information

Advanced Computer Programming

Advanced Computer Programming Hazırlayan Yard. Doç. Dr. Mehmet Fidan VARIABLE TYPES Integral Types: In C#, an integral is a category of types. For anyone confused because the word Integral sounds like a mathematical term, from the

More information

Cpt S 122 Data Structures. Introduction to C++ Part II

Cpt S 122 Data Structures. Introduction to C++ Part II Cpt S 122 Data Structures Introduction to C++ Part II Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Objectives Defining class with a member function

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

Introduction to.net Framework

Introduction to.net Framework Introduction to.net Framework .NET What Is It? Software platform Language neutral In other words:.net is not a language (Runtime and a library for writing and executing written programs in any compliant

More information

These are notes for the third lecture; if statements and loops.

These are notes for the third lecture; if statements and loops. These are notes for the third lecture; if statements and loops. 1 Yeah, this is going to be the second slide in a lot of lectures. 2 - Dominant language for desktop application development - Most modern

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify

More information

CHAPTER 7 OBJECTS AND CLASSES

CHAPTER 7 OBJECTS AND CLASSES CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and

More information

C # Language Specification

C # Language Specification C # Language Specification Copyright Microsoft Corporation 1999-2001. All Rights Reserved. Please send corrections, comments, and other feedback to sharp@microsoft.com Notice 1999-2001 Microsoft Corporation.

More information

Sri Vidya College of Engineering & Technology

Sri Vidya College of Engineering & Technology UNIT I INTRODUCTION TO OOP AND FUNDAMENTALS OF JAVA 1. Define OOP. Part A Object-Oriented Programming (OOP) is a methodology or paradigm to design a program using classes and objects. It simplifies the

More information

1. Introduction to the Common Language Infrastructure

1. Introduction to the Common Language Infrastructure Miller-CHP1.fm Page 1 Wednesday, September 24, 2003 1:50 PM to the Common Language Infrastructure The Common Language Infrastructure (CLI) is an International Standard that is the basis for creating execution

More information

PES INSTITUTE OF TECHNOLOGY

PES INSTITUTE OF TECHNOLOGY Seventh Semester B.E. IA Test-I, 2014 USN 1 P E I S PES INSTITUTE OF TECHNOLOGY C# solution set for T1 Answer any 5 of the Following Questions 1) What is.net? With a neat diagram explain the important

More information

CS260 Intro to Java & Android 03.Java Language Basics

CS260 Intro to Java & Android 03.Java Language Basics 03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance

More information

INTERNAL ASSESSMENT TEST 1 ANSWER KEY

INTERNAL ASSESSMENT TEST 1 ANSWER KEY INTERNAL ASSESSMENT TEST 1 ANSWER KEY Subject & Code: C# Programming and.net-101s761 Name of the faculty: Ms. Pragya Q.No Questions 1 a) What is an assembly? Explain each component of an assembly. Answers:-

More information

Learning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo

Learning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo Learning C# 3.0 Jesse Liberty and Brian MacDonald O'REILLY Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo Table of Contents Preface xv 1. C# and.net Programming 1 Installing C# Express 2 C# 3.0

More information

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output Last revised January 12, 2006 Objectives: 1. To introduce arithmetic operators and expressions 2. To introduce variables

More information

Basics of Java Programming

Basics of Java Programming Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement

More information

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships

More information

Tools : The Java Compiler. The Java Interpreter. The Java Debugger

Tools : The Java Compiler. The Java Interpreter. The Java Debugger Tools : The Java Compiler javac [ options ] filename.java... -depend: Causes recompilation of class files on which the source files given as command line arguments recursively depend. -O: Optimizes code,

More information

Introduction to.net Framework Week 1. Tahir Nawaz

Introduction to.net Framework Week 1. Tahir Nawaz Introduction to.net Framework Week 1 Tahir Nawaz .NET What Is It? Software platform Language neutral In other words:.net is not a language (Runtime and a library for writing and executing written programs

More information

Objectives. In this chapter, you will:

Objectives. In this chapter, you will: Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about

More information

Object-Oriented Programming in C# (VS 2015)

Object-Oriented Programming in C# (VS 2015) Object-Oriented Programming in C# (VS 2015) This thorough and comprehensive 5-day course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes

More information

Module 2: Introduction to a Managed Execution Environment

Module 2: Introduction to a Managed Execution Environment Module 2: Introduction to a Managed Execution Environment Contents Overview 1 Writing a.net Application 2 Compiling and Running a.net Application 11 Lab 2: Building a Simple.NET Application 29 Review 32

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring

More information

M4.1-R4: APPLICATION OF.NET TECHNOLOGY

M4.1-R4: APPLICATION OF.NET TECHNOLOGY M4.1-R4: APPLICATION OF.NET TECHNOLOGY NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered in the OMR

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

CHAPTER 7 OBJECTS AND CLASSES

CHAPTER 7 OBJECTS AND CLASSES CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

C# Syllabus. MS.NET Framework Introduction

C# Syllabus. MS.NET Framework Introduction C# Syllabus MS.NET Framework Introduction The.NET Framework - an Overview Framework Components Framework Versions Types of Applications which can be developed using MS.NET MS.NET Base Class Library MS.NET

More information

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

Chapter 1: A First Program Using C#

Chapter 1: A First Program Using C# Chapter 1: A First Program Using C# Programming Computer program A set of instructions that tells a computer what to do Also called software Software comes in two broad categories System software Application

More information

Chapter 3: Operators, Expressions and Type Conversion

Chapter 3: Operators, Expressions and Type Conversion 101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

Introduction to.net, C#, and Visual Studio. Part I. Administrivia. Administrivia. Course Structure. Final Project. Part II. What is.net?

Introduction to.net, C#, and Visual Studio. Part I. Administrivia. Administrivia. Course Structure. Final Project. Part II. What is.net? Introduction to.net, C#, and Visual Studio C# Programming Part I Administrivia January 8 Administrivia Course Structure When: Wednesdays 10 11am (and a few Mondays as needed) Where: Moore 100B This lab

More information

Object-Oriented Programming in C# (VS 2012)

Object-Oriented Programming in C# (VS 2012) Object-Oriented Programming in C# (VS 2012) This thorough and comprehensive course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes the C#

More information

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

More information

UEE1302 (1102) F10: Introduction to Computers and Programming

UEE1302 (1102) F10: Introduction to Computers and Programming Computational Intelligence on Automation Lab @ NCTU Learning Objectives UEE1302 (1102) F10: Introduction to Computers and Programming Programming Lecture 00 Programming by Example Introduction to C++ Origins,

More information

Fundamental Concepts and Definitions

Fundamental Concepts and Definitions Fundamental Concepts and Definitions Identifier / Symbol / Name These terms are synonymous: they refer to the name given to a programming component. Classes, variables, functions, and methods are the most

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

Chapter 2: Using Data

Chapter 2: Using Data Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that

More information

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java Chapter 3 Syntax, Errors, and Debugging Objectives Construct and use numeric and string literals. Name and use variables and constants. Create arithmetic expressions. Understand the precedence of different

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including: Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including: Abstraction Encapsulation Inheritance and Polymorphism Object-Oriented

More information

Maciej Sobieraj. Lecture 1

Maciej Sobieraj. Lecture 1 Maciej Sobieraj Lecture 1 Outline 1. Introduction to computer programming 2. Advanced flow control and data aggregates Your first program First we need to define our expectations for the program. They

More information

Microsoft. Microsoft Visual C# Step by Step. John Sharp

Microsoft. Microsoft Visual C# Step by Step. John Sharp Microsoft Microsoft Visual C#- 2010 Step by Step John Sharp Table of Contents Acknowledgments Introduction xvii xix Part I Introducing Microsoft Visual C# and Microsoft Visual Studio 2010 1 Welcome to

More information