Data Types Flashcards

1
Q

Namespace

A

Namespaces provide a hierarchical means of organizing C# programs and libraries.

Namespaces contain types and other namespaces—for example, the System namespace contains many types, such as the Console class referenced in the program, and many other namespaces, such as IO and Collections

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

using

A

A using directive that references a given namespace enables unqualified use of the types that are members of that namespace.

Because of the using directive, the program can use Console.WriteLine as shorthand for System.Console.WriteLine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Access Modifiers

A
  1. public: Access isn’t restricted.
  2. private: Access is limited to the containing type, only in same class
  3. file: The declared type is only visible in the current source file.
    File scoped types are generally used for source generators.
  4. internal: Access is limited to the current assembly.- only in assembly, same namespace/ project
  5. protected: Access is limited to the containing class
    or types derived from the containing class- class and the classes
    that derived from it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

2 types of protected acess modifiers

A

proteced: private and internal

  1. private protected: Access is limited to the containing class or
    types derived from the containing class within the current assembly
  2. protected internal: Access is limited to the current
    assembly or types derived from the containing class.

W C# oraz .NET, assembly to podstawowy blok wykonywalny aplikacji, który może być plikiem wykonywalnym (.exe) lub biblioteką (.dll).

Assembly to jednostka wdrożenia, która zawiera kod, zasoby, a także informacje o metadanych niezbędne do wykonania tego kodu.

Termin current assembly odnosi się do tego konkretnego assembly, w którym aktualnie znajduje się kod, czyli kod wykonujący się w danym momencie. Jest to po prostu assembly, w którym znajduje się definicja klasy lub członka, którego dotyczy kontrola dostępu.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

2 types of values

A

based on how they occupy the memory
1. value type
2. reference type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

value type

A

stored directly
typically stored in stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

reference type

A

stores the memory location of data, variable

stores memory reference, not value directly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

value type

A
  1. primitives
  2. nullable version
  3. struct
  4. enum
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

reference type

A
  1. class
  2. interface
  3. array
  4. delegates
  5. string

acdis

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Primitive data types

A
  1. integral- sbyte, short, integer, long
  2. floating point- float, double, decimal
  3. boolean-bool
  4. unicode characters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

2 types of conversion

A

implicit- no risk of losing data
explicit- with risk of losing data, double to int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

var

A

-from c# 3.0, to declare local variables
-compiler determines the data type
-cannot be null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Encapsulation

A

Encapsulation- practice of hiding the internal state of an object and allowing access and modification through methods

-Data integrity
-Reduce complexity
-Abstraction- hide the implementation details

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Private field logic

A

public property- getters and setters accessors, control access

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

auto-implemented properties

A

automaticlly creates a field ,
automaticlly creats a getter and a setter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Finalizer/Destructor

A
  • class can have only one finalizer, define with ~, cannot be overloaded or inherited
    -when object is destroyed, is out of scoped
    -cleanup statement
17
Q

Inheritance

A

define a class within another class,
A class can inherint from a single class and multiple interfaces

18
Q

virtual keyword

A

can be overridden in classes that inherits from this class
then we use override keyword

19
Q

Polymorhpish

A

using new keyword in the method is not a overrridening but giving higher priority

20
Q

sealed keyword-

A

the method or a class cannot be overridden

21
Q

abstract class

A

class- cannot create an instance of abstract class, just the blueprint

method- a method that has to be implemented!

22
Q

to compare if is an instance of a class-

A

as/ is keyword
Cube iceCube = element as Cube
if element is Cube

23
Q

Abstract classes and interfaces

A

cant create an instance of it

both support polymorphism

24
Q

Abstract classes and interfaces compare

A

Abstract classes:

can have constructor

can be partially implemented

can contain fields

only one inherit

-> AND Interfaces cant and class implement many

25
Q

Reading a file

A

System.IO.File.ReadAllText

26
Q

Writing to a file

A

File.WriteAllLines(path, file)
using(System.StreamWriter file = new StreamWriter()

27
Q

3 types of collection

A
  1. Array
  2. List
  3. ArrayList
28
Q

Array

A

-fixed size
-generic- everything has to be same sized

29
Q

List

A
  • can be resized dynamically but arrays cannot.
    generic- everything has to be same sized
  • can accept null as a valid value for reference types and it
    also allows duplicate elements.
30
Q

ArrayList

A

-is resizeable
-can have object of diffrent type
-cannot implement a multi-dimensional
array using ArrayList.

31
Q

Multi-dimensional array

A

[,] - two dimensioms array- matrix
[,,] - three dimensions array
.Rank- returns a dimension of an array

32
Q

Jagged Array-

A

an array inside an array
int[][] jaggedArr= new int[3][]

array with 3 arrays

33
Q

params keyword-

A

Dictionaries- generic collections