Presentation is loading. Please wait.

Presentation is loading. Please wait.

C# Language & .NET Platform 9th Lecture

Similar presentations


Presentation on theme: "C# Language & .NET Platform 9th Lecture"— Presentation transcript:

1 C# Language & .NET Platform 9th Lecture
Pavel Ježek Some of the slides are based on University of Linz .NET presentations. © University of Linz, Institute for System Software, 2004 published under the Microsoft Curriculum License (

2 CLI Type System All types Value types Reference types Pointers
(allocated in-place [with exceptions]) Reference types (allocated on managed heap) Pointers Structures Enumerations Classes (e.g. strings) Interfaces Arrays Delegates Simple types (Int32, Int64, Double, Boolean, Char, …) Nullables User defined structures

3 Visibility class private struct private Visibility modifiers:
public Access is not restricted. protected Access is limited to the containing class or types derived from the containing class. internal Access is limited to the current assembly. protected internal Access is limited to the current assembly or types derived from the containing class. private Access is limited to the containing type. Default visibility in: enum public class private interface public struct private

4 CLI Type System All types Value types Reference types Pointers
(allocated in-place [with exceptions]) Reference types (allocated on managed heap) Pointers Structures Enumerations Classes (e.g. strings) Interfaces Arrays Delegates Simple types (Int32, Int64, Double, Boolean, Char, …) Nullables User defined structures

5 Parameters - "call by value"
value parameters (input parameters) void Inc(int x) {x = x + 1;} void f() { int val = 3; Inc(val); // val == 3 } - "call by value" - formal parameter is a copy of the actual parameter - actual parameter is an expression

6 Parameters - "call by value"
value parameters (input parameters) void Inc(int x) {x = x + 1;} void f() { int val = 3; Inc(val); // val == 3 } - "call by value" - formal parameter is a copy of the actual parameter - actual parameter is an expression - "call by reference" - formal parameter is an alias for the actual parameter (address of actual parameter is passed) - actual parameter must be a variable ref parameters (transient parameters) void Inc(ref int x) { x = x + 1; } void f() { int val = 3; Inc(ref val); // val == 4 }


Download ppt "C# Language & .NET Platform 9th Lecture"

Similar presentations


Ads by Google