Unit 1:DOT NET Framework CLR(Common Language Runtime )
priyankajadhav6600
341 views
24 slides
Aug 01, 2024
Slide 1 of 24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
About This Presentation
1.1 Introduction to DOTNET
1.2 DOT NET class framework
1.3 Common Language Runtime
1.3.1 Overview
1.3.2 Elements of .NET application
1.3.3 Memory Management
1.3.4 Garbage Collector : Faster Memory allocation, Optimizations
1.4 Common Language Integration
1.4.1 Common type system
1.4.2 Refl...
1.1 Introduction to DOTNET
1.2 DOT NET class framework
1.3 Common Language Runtime
1.3.1 Overview
1.3.2 Elements of .NET application
1.3.3 Memory Management
1.3.4 Garbage Collector : Faster Memory allocation, Optimizations
1.4 Common Language Integration
1.4.1 Common type system
1.4.2 Reflection API
1.5 User and Program Interface
Size: 1.09 MB
Language: en
Added: Aug 01, 2024
Slides: 24 pages
Slide Content
M. SC. (Computer Science) Course Code : 23CsCmpP121 Course Name : DOT NET Presented By : Priyanka Jadhav Modern College of Arts,Science and Commerce ,Pune-5
Notes Chapter 2 Introduction to C#
Chapter 2 Introduction to C# Points to be covered in today’s Lecture
. Chapter 2 Introduction to C# 2.1.1 Variables and Expressions,typeconversion Variables and constant are basic building block of programming language . A variable is a name given to memory location whose value may change during the program execution. C# syntax for declaring variables:- < datatype > < varname >; For example : int num; On the other hand , a constant is a value which never changes during the program execution. C# syntax for declaring constant: <const>< datatype > < constName >; For example: const int num;
. Chapter 2 Introduction to C# 2.1.1 Variables and Expressions,typeconversion Expressions:- An expression in C# is a combination of operands (variables, literals, method calls) and operators that can be evaluated to a single value. To be precise, an expression must have at least one operand but may not have any operator. Let's look at the example below: double temperature; temperature = 42.05; int a, b, c, sum; sum = a + b + c; if (age>=18 && age<58) Console.WriteLine ("Eligible to work");
. Chapter 2 Introduction to C# 2.1.1 Variables and Expressions,typeconversion Datatypes in C#:-
. Chapter 2 Introduction to C# 2.1.1 Variables and Expressions,typeconversion Console Class in C# :- Methods of Console class in C#: Method Description Clear() To clear the screen Write(“string”) Display the specified message on the console window WriteLine(“string”) Same as the write method but automatically moves the cursor to the next line after printing the message. Write(variable) Displays the value of the given variable WriteLine(variable) Displays the value of the given variable along with moving the cursor to the next line after printing the value of the variable.
. Chapter 2 Introduction to C# 2.1.1 Variables and Expressions,typeconversion Console Class in C# :- Methods of Console class in C#: Method Description Read() Read a single character from the keyboard and returns its ASCII value. The Datatype should be int as it returns the ASCII value. ReadLine () Reads a string value from the keyboard and returns the entered value only. As it returns the entered string value so the DataType is going to be a string. ReadKey () read any key from the console. By entering this line of code, the program will wait and not exit immediately. The program will wait for the user to enter any key before finally exiting. If you don't include this statement in code, the program will exit as soon as it is run.
. Chapter 2 Introduction to C# 2.1.1 Variables and Expressions,typeconversion Typeconversion :- to be cont…
C# Type Casting Type casting is when you assign a value of one data type to another type. In C#, there are two types of casting: Implicit Casting (automatically) - converting a smaller type to a larger type size char -> int -> long -> float -> double Explicit Casting (manually) - converting a larger type to a smaller size type double -> float -> long -> int -> char
. Conversion Methods Int.Parse () Convert Class Int.TryParse() It is used to convert string to int It is used to convert any datatype to int It is used to convert string to int Can not handle null values Can handle null values Can handle null values Will not check whether the type of parsing is valid or invalid Will not check whether the type of parsing is valid or invalid Will check whether the type of parsing is valid or invalid 2.1.1 Variables and Expressions,typeconversion Chapter 2 Introduction to C# 2.1.1 Variables and Expressions,typeconversion
Chapter 2 Introduction to C# 2.1.2 Flow Control Flow Control allows us to execute code based on some conditions. It also allows to execute the code specified number of times. Following are the Flow control statements:- Selection statements are used to select one of number of possible statements for execution b ased on the value of some expression. In this group are if and switch statements. Iteration statements are used to repeatedly execute an embedded statements. In this group are the while,do,for,and foreach statements . Jump statements are used to transfer control. In this group are the break,continue,goto,throw,return,and yield statements.
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- In C# a function is defined as a technique of wrapping code to perform a certain task and then return a value. It is quite different than its predecessor programming languages like C or C++. Here the functions do not exist alone. Functions are a part of the OOPs approach. <visibility> <return type > <name> ( <parameters> ) { <function code > } to be cont…
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- public void DoStuff () { Console.WriteLine ("I'm doing something..."); } public int AddNumbers ( int number1, int number2) { int result = number1 + number2; return result; } int result = AddNumbers (10, 5); Console.WriteLine (result);
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- What is a Parameter? Parameter define the set of arguments that must be provided for that method. Example -: void calculate( int a, string b);
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- Parameter Modifiers Usually methods take parameters. There are many ways to pass the parameters and for this C# provides some parameter modifiers. Look at them below. none (or default) parameter ref (reference) parameter out (output) parameter params (parameters) parameter
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- Parameter Modifiers none (or default) parameter: - If a parameter is not attached with any modifier, then the parameter's value is passed to the method. This is also known as call-by-value and it is the default for any parameter. X = 20; Console.WriteLine (x);
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- Parameter Modifiers 2. ref (reference) parameter : C# provides the ref parameter modifier, to pass argument by reference. To pass by reference the ref modifier should be used when declaring and calling the method. to be cont…
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- Parameter Modifiers to be cont… 2. ref (reference) parameter: - If a parameter is attached with a ref modifier, then changes will be made in a method that affect the calling method. This is also known as call-by-reference. X = 20; Console.WriteLine (&x );
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- Parameter Modifiers to be cont… 3.out (output) parameter: C# provides the out parameter modifier which is similar to ref arguments. To pass by reference the out modifier should be used when declaring and calling the method. to be cont…
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- Parameter Modifiers 3.out (output) parameter: - If a parameter is attached with an out modifier, then we can return a value to a calling method without using a return statement.
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- Parameter Modifiers 4. params (parameters) parameter: - If a parameter is attached with a params modifier , then we can send multiple arguments as a single parameter. Any method can have only one params modifier and it should be the last parameter for the method.
Chapter 2 Introduction to C# 2.1.3 Functions, Delegates Functions:- Parameter Modifiers differences between output (out) and reference (ref) parameters: Ref parameters Needs to be initialized before passing it to the function. Out parameters Need not be initialized while calling the function. But need to be initialized in the called function.
Questions W hat is variable and expression? What are the Console Classes in C#? Type Conversion Methods? C# type Casting? What is flow control and flow control statements? What is functions how we call the functions? What are the Access control? Define Parameter and Parameter modifiers Chapter 2 Introduction to C#