×
Study for the day when you don't have to worry about price tags.
--Your friends at LectureNotes
Close

Note for C# and .NET - C#.NET By ANNA SUPERKINGS

  • C# and .NET - C#.NET
  • Note
  • 6 Topics
  • 3929 Views
  • 282 Offline Downloads
  • Uploaded 11 months ago
Anna Superkings
Anna Superkings
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-2

hello, world Close examination of this program is illuminating: The using System; directive references a namespace called System that is provided by the Microsoft .NET Framework class library. This namespace contains the Console class referred to in the Main method. Namespaces provide a hierarchical means of organizing the elements of one or more programs. A "using" directive enables unqualified use of the types that are members of the namespace. The "hello, world" program uses Console.WriteLine as shorthand for System.Console.WriteLine. The Main method is a member of the class Hello. It has the static modifier, and so it is a method on the class Hello rather than on instances of this class. The entry point for an application — the method that is called to begin execution — is always a static method named Main. The "hello, world" output is produced using a class library. The language does not itself provide a class library. Instead, it uses a class library that is also used by Visual Basic .NET and Visual C++ .NET. For C and C++ developers, it is interesting to note a few things that do not appear in the "hello, world" program. The program does not use a global method for Main. Methods and variables are not supported at the global level; such elements are always contained within type declarations (e.g., class and struct declarations). The program does not use either "::" or "->" operators. The "::" is not an operator at all, and the "->" operator is used in only a small fraction of programs — those that employ unsafe code (Section A). The separator "." is used in compound names such asConsole.WriteLine. The program does not contain forward declarations. Forward declarations are never needed, as declaration order is not significant. The program does not use #include to import program text. Dependencies among programs are handled symbolically rather than textually. This approach eliminates barriers between applications written using multiple languages. For example, the Console class need not be written in C#. C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its .NET initiative led by Anders Hejlsberg. This tutorial will teach you basic C# programming and will also take you through various advanced concepts related to C# programming language. sample code using System; CS6001 C# and .Net programming Page 2

Text from page-3

namespace HelloWorldApplication { class HelloWorld { static void Main(string[] args) { /* my first program in C# */ Console.WriteLine("Hello World"); Console.ReadKey(); } } } C# is a modern, general-purpose, object-oriented programming language developed by Microsoft and approved by European Computer Manufacturers Association (ECMA) and International Standards Organization (ISO). C# was developed by Anders Hejlsberg and his team during the development of .Net Framework. C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows use of various high-level languages on different computer platforms and architectures. The following reasons make C# a widely used professional language: It is a modern, general-purpose programming language It is object oriented. It is component oriented. It is easy to learn. It is a structured language. It produces efficient programs. It can be compiled on a variety of computer platforms. It is a part of .Net Framework. Strong Programming Features of C# Although C# constructs closely follow traditional high-level languages, C and C++ and being an object-oriented programming language. It has strong resemblance with Java, it has numerous strong programming features that make it endearing to a number of programmers worldwide. Following is the list of few important features of C#: Boolean Conditions Automatic Garbage Collection CS6001 C# and .Net programming Page 3

Text from page-4

SRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY,VIRUDHUNAGRA COURSE MATERIAL (LECTURE NOTES) Standard Library Assembly Versioning Properties and Events Delegates and Events Management Easy-to-use Generics Indexers Conditional Compilation Simple Multithreading LINQ and Lambda Expressions Integration with Windows CS6001 C# and .Net programming Page 4

Text from page-5

SRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY,VIRUDHUNAGRA COURSE MATERIAL (LECTURE NOTES) Literals and Constants The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well. The constants are treated just like regular variables except that their values cannot be modified after their definition. Integer Literals An integer literal can be a decimal, octal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, 0 for octal, and no prefix id for decimal. An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively. The suffix can be uppercase or lowercase and can be in any order. Here are some examples of integer literals: 212 /* Legal */ 215u /* Legal */ 0xFeeL /* Legal */ 078 /* Illegal: 8 is not an octal digit */ 032UU /* Illegal: cannot repeat a suffix */ Following are other examples of various types of Integer literals: 85 0213 0x4b 30 30u 30l 30ul /* decimal */ /* octal */ /* hexadecimal */ /* int */ /* unsigned int */ /* long */ /* unsigned long */ Floating-point Literals A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or exponential form. Here are some examples of floating-point literals: CS6001 C# and .Net programming Page 5

Lecture Notes