Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver1
9いいね 3,229 views回再生

Encapsulation vs Abstraction

C# is strongly typed, case sensitive language and provides full support for Object oriented programming including abstraction, encapsulation, inheritance, and polymorphism. Abstraction means hiding the unnecessary details from type consumers. Encapsulation means that a group of related properties, methods, and other members are treated as a single unit or object.
The main advantage of using encapsulation is the security of the data
Make the instance variables private so that they cannot be accessed directly from outside the class. You can only set and get values of these variables through the methods of the class

Access modifiers : private, public, internal, protected and protected internal

public - public inside and outside the assembly (public internal / public external)

protected - protected inside and outside the assembly (protected internal / protected external) (not allowed on top level classes)

private - private inside and outside the assembly (private internal / private external) (not allowed on top level classes)

internal - public inside the assembly but excluded outside the assembly like private (public internal / excluded external)

protected internal - public inside the assembly but protected outside the assembly (public internal / protected external) (not allowed on top level classes)

コメント