C# Questions I Flashcards

1
Q

Name different types errors which can occur during the execution of a program?

A

There are three types of errors which can occur during the execution of a program.

Syntax Errors

Runtime Errors

Logical errors

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

When a syntax error occurs?

A

A syntax error occurs when the program violates one or more grammatical rules of the programming language. These errors are detected at compile time, i.e., when the translator (compiler or interpreter) attempts to translate the program.

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

When a runtime error occurs?

A

A runtime error occurs when the computer is directed to perform an illegal operation by the program such as dividing a number by zero.

Runtime errors are the only errors which are displayed immediately during the execution of a program. When these errors occur, the computer stops the execution of the programming and can display a diagnostic message that will help in locating the error.

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

When a logical error occurs?

A

The logical error happens when a program implements a wrong logic. The translator (compiler or interpreter) does not report any error message for a logical error. These errors are the most difficult to locate.

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

What is Machine code?

A

Machine code is a language, which can be processed directly by a microprocessor without any need of the previous transformation.

Programmers never write programs directly in machine code.

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

What is modeling language?

A

An artificial language that can be used to express information or knowledge or systems in an arrangement which is defined by a reliable number of rules. These rules are also used for interpretation of the meaning of components in the structure.

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

What does a break statement do in the switch statement?

A

The switch statement is a selection control statement that is used to handle multiple choices and transfer control to the case statements within its body. The following code snippet shows an example of the use of the switch statement in C#:

switch(choice) { case 1: console.WriteLine(First); break; case 2: console.WriteLine(Second); break; default: console.WriteLine(Wrong choice); break; }

In switch statements, the break statement is used at the end of a case statement. The break statement is mandatory in C# and it avoids the fall through of one case statement to another.

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

What is the main difference between sub-procedure and function?

A

The sub-procedure is a block of multiple visual basic statements within Sub and End Sub statements. It is used to perform certain tasks, such as changing properties of objects, receiving or processing data, and displaying an output. You can define a sub-procedure anywhere in a program, such as in modules, structures, and classes.

We can also provide arguments in a sub-procedure; however, it does not return a new value.The function is also a set of statements within the Function and End Function statements.It is similar to sub - procedure and performs the same task.The main difference between a function and a sub - procedure is that sub - procedures do not return a value while functions do.

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

Differentiate between Boxing and Unboxing.

A

When a value type is converted to an object type, the process is known as boxing;

whereas, when an object type is converted to a value type, the process is known as unboxing.

Boxing and unboxing enable value types to be treated as objects.

Boxing a value type packages it inside an instance of the Object reference type. This allows the value type to be stored on the garbage collected heap. Unboxing extracts the value type from the object. In this example, the integer variable iis boxed and assigned to object obj.

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

What is the difference between a struct and a class in C#?

A

Class and Struct both are the user defined data type but have some major difference:

Struct
* The struct is value type in C# and it inherits from System.Value Type.
* Struct is usually used for smaller amounts of data.
* Struct can’t be inherited to other type.
* A structure can’t be abstract.
* No need to create object by new keyword.
* Do not have permission to create any default constructor.

Class

  • The class is reference type in C# and it inherits from the System.Object Type.
  • Classes are usually used for large amounts of data.
  • Classes can be inherited to other class.
  • A class can be abstract type.
  • We can’t use an object of a class with using new keyword.
  • We can create a default constructor.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Struct

A
  • The struct is value type in C# and it inherits from System.Value Type.
  • Struct is usually used for smaller amounts of data.
  • Struct can’t be inherited to other type.
  • A structure can’t be abstract.
  • No need to create object by new keyword.
  • Do not have permission to create any default constructor.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Class

A
  • The class is reference type in C# and it inherits from the System.Object Type.
  • Classes are usually used for large amounts of data.
  • Classes can be inherited to other class.
  • A class can be abstract type.
  • We can’t use an object of a class with using new keyword.
  • We can create a default constructor.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an Abstract Class?

A

Nie można tworzyć instancji klasy abstrakcyjnej: Nie można utworzyć obiektu z klasy abstrakcyjnej. Służy ona do dziedziczenia przez inne klasy.

Może zawierać metody abstrakcyjne: Metoda abstrakcyjna to metoda, która nie ma implementacji (definicji) w klasie abstrakcyjnej, i musi być zaimplementowana w klasie dziedziczącej.

Może zawierać metody z implementacją: Klasa abstrakcyjna może także zawierać metody z pełną implementacją, które nie muszą być zmieniane przez klasy pochodne.

Może zawierać właściwości, pola, konstruktory: Klasy abstrakcyjne mogą mieć właściwości, pola, a także konstruktory, które mogą być używane przez klasy pochodne.

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

What is an Interface?

A

An interface contains only the signatures of methods, properties, events or indexers. A class or struct that implements the interface must implement the members of the interface that are specified in the interface definition.

An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body.

As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments.

The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class.

Since C# doesn’t support multiple inheritance, interfaces are used to implement multiple inheritance.

When we create an interface, we are basically creating a set of methods without any implementation that must be overridden by the implemented classes. The advantage is that it provides a way for a class to be a part of two classes: one from inheritance hierarchy and one from the interface.

When we create an abstract class, we are creating a base class that might have one or more completed methods but at least one or more methods are left uncompleted and declared abstract. If all the methods of an abstract class are uncompleted then it is same as an interface. The purpose of an abstract class is to provide a base class definition for how a set of derived classes will work and then allow the programmers to fill the implementation in the derived classes.

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

What is enum in C#?

A

An enum is a value type with a set of related named constants often referred to as an enumerator list.

The enum keyword is used to declare an enumeration. It is a primitive data type, which is user defined.

An enum type can be an integer (float, int, byte, double etc.). But if you used beside int it has to be cast.

An enum is used to create numeric constants in .NET framework. All the members of enum are of enum type. There must be a numeric value for each enum type.

The default underlying type of the enumeration element is int. By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1.

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

What is the difference between “continue” and “break” statements in C#?

A

Using break statement, you can ‘jump out of a loop’ whereas by using continue statement, you can ‘jump over one iteration’ and then resume your loop execution.

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

What is the difference between constant and readonly in c#?

A

Constants perform the same tasks as read-only variables with some differences. The differences between constants and read-only are

Constants:
1.Constants are dealt with at compile-time.
2.Constants supports value-type variables.
3.Constants should be used when it is very unlikely that the value will ever change.
4. Implicitly static, meaning it belongs to the type, not an instance of the type. You cannot mark a const as static explicitly.

CONST IS COMPILE AND STATIC

Read-only:
1. Read-only variables * are evaluated at runtime**.
2. Read-only variables can hold reference type variables.
3. Read-only variables should be used when run-time calculation is required.
4. Can be assigned either at the time of declaration or in the constructor of the class.
5. Can be used as instance-level or static. If marked static, it applies to the class, otherwise, it’s tied to an instance.

READONLY IS RUNTIME AND INSTANCE LEVEL

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

What are 3 types of parameters?

A

In C Sharp (C#) we can have three types of parameters in a function. The parameters can be

in parameter (which is not returned back to the caller of the function),

out (return muliple values) parameter and

ref parameter. Both ref and out are treated differently at run time and they are treated the same at compiler properties are not variables, therefore it cannot be passed as an out or ref parameter

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

Ref

A

THE PARAMETER HAVE TO HAVE A VALUE BEFORE THE FUNCTION CALL!

THE PARAMETER DONT HAVE TO BE CHANGED IN FUNCTION

WHEN WE WANT TO PASS A PARAMETER TO A FUNCTION AND THEN CHANGE IT

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

Out

A

THE PARAMETER DONT HAVE TO HAVE A VALUE BEFORE THE FUNCTION CALL, BUT HAVE TO HAVE VALUE BEFORE THE FUNCTION RETURN

THE PARAMETER HAVE TO BE CHANGED IN FUNCTION

WHEN WE WANT TO RETURN MULTIPLE VALUES

21
Q

Can “this” be used within a static method?

A

We can’t use this in static method because keyword ‘this’ returns a reference to the current instance of the class containing it.

Static methods (or any static member) do not belong to a particular instance. They exist without creating an instance of the class and call with the name of a class not by instance so we can’t use this keyword in the body of static Methods, but in case of Extension Methods we can use it the functions parameters. Let’s have a look on “this” keyword.

The “this” keyword is a special type of reference variable that is implicitly defined within each constructor and non-static method as a first parameter of the type class in which it is defined. For example, consider the following class written in C#.

22
Q

Define Property in C# .net?

A

Properties are members that provide a flexible mechanism to read, write or compute the values of private fields, in other words by the property we can access private fields.

In other words we can say that a property is a return type function/method with one parameter or without a parameter. These are always public data members.

It uses methods to access and assign values to private fields called accessors.

23
Q

What are accessors?

A

The get and set portions or blocks of a property are called accessors.

These are useful to restrict the accessibility of a property, the set accessor specifies that we can assign a value to a private field in a property and without the set accessor property it is like a read-only field.

By the get accessor we can access the value of the private field, in other words it returns a single value. A Get accessor specifies that we can access the value of a field publicly.

We have the three types of properties

getters and setters

* Read/Write.
* ReadOnly.
* WriteOnly

24
Q

What is extension method in c# and how to use them?

A

Extension methods enable you to add methods to existing types without creating a new derived type (classess, structures, interfaces), recompiling, or otherwise modifying the original type.

An extension method is a special kind of static method, but they are called as if they were instance methods on the extended type.

  • public static string ReverseString(this string str)
    {
    char[] charArray = str.ToCharArray();
    Array.Reverse(charArray);
    return new string(charArray);
    }*

METODA STATYCZNA KTÓRA ROZSZERZA ISTNIEJĄCY TYP

25
Q

How to use extension methods?

A

An extension method is a static method of a static class, where the “this” modifier is applied to the first parameter. The type of the first parameter will be the type that is extended.

Extension methods in C# allow you to add new functionality to existing types (classes, structs, interfaces) without modifying their source code. They are especially useful when you want to extend the functionality of a class that you don’t have control over (like built-in types or types from third-party libraries) or when you want to add methods to types without creating a new derived class.

26
Q

What is the difference between string and StringBuilder in c#?

A

StringBuilder and string both use to store string value but both have many differences on the bases of instance creation and also for performance:

String:

String is an immutable object. Immutable like when we create string object in code so we cannot modify or change that object in any operations like insert new value, replace or append any value with existing value in string object, when we have to do some operations to change string simply it will dispose the old value of string object and it will create new instance in memory for hold the new value in string object like

  • It’s an immutable object that holds string value.
  • Performance wise string is slow because its’ create a new instance to override or change the previous value.
  • String belongs to System namespace.

StringBuilder:

System.Text.Stringbuilder is mutable object which also hold the string value, mutable means once we create a System.Text.Stringbuilder object we can use this object for any operation like insert value in existing string with insert functions also replace or append without creating new instance of System.Text.Stringbuilder for every time so it’s use the previous object so it’s work fast as compare than System.String.

  • StringBuilder is a mutable object.
  • Performance wise StringBuilder is very fast because it will use same instance of StringBuilder object to perform any operation like insert value in existing string.
  • StringBuilder belongs to System.Text.Stringbuilder namespace.
27
Q

What are delegates in C# and uses of delegates?

A

A delegate object encapsulates a reference to a method.

C# delegates are same as pointers to functions, in C or C++.

A delegate Object is a reference type variable that use to holds the reference to a method.

The reference can be changed at runtime which is hold by an object of delegate, a delegate object can hold many functions reference which is also known as Invocation List that refers functions in a sequence FIFO, we can new functions ref in this list at run time by += operator and can remove by -= operator.

Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegate class.

28
Q

What is sealed class in c#?

A

Sealed classes are used to restrict the inheritance feature of object oriented programming. Once a class is defined as a sealed class, the class cannot be inherited.

29
Q

What are partial classes?

A

A partial class is only use to splits the definition of a class in two or more classes in a same source code file or more than one source files.

You can create a class definition in multiple files but it will be compiled as one class at run time and also when you’ll create an instance of this class so you can access all the methods from all source file with a same object.

Partial Classes can be create in the same namespace it’s doesn’t allowed to create a partial class in different namespace.

So use “partial” keyword with the entire class name which you want to bind together with the same name of class in same namespace.

30
Q

What is IEnumerable<> in c#?

A

IEnumerable is the parent interface for all non-generic collections in System.Collections namespace like ArrayList, HastTable etc. that can be enumerated.

For the generic version of this interface as IEnumerable which a parent interface of all generic collections class in System.Collections.Generic namespace like List<> and more.

In System.Collections.Generic.IEnumerable have only a single method which is GetEnumerator() that returns an IEnumerator.

IEnumerator provides the power to iterate through the collection by exposing a Current property and Move Next and Reset methods, if we doesn’t have this interface as a parent so we can’t use iteration by foreach loop or can’t use that class object in our LINQ query.

umożliwia korzystanie z foreach
GetEnumerator()- zwraca enumerator

31
Q

What is difference between late binding and early binding in c#?

A

Early Binding and Late Binding concepts belongs to polymorphism so let’s see first about polymorphism: \

Polymorphism is an ability to take more than one form of a function means with a same name we can write multiple functions code in a same class or any derived class.

Polymorphism we have 2 different types to achieve that:

  • Compile Time also known as Early Binding or Overloading.
  • Run Time also known as Late Binding or Overriding.

Compile Time Polymorphism or Early Binding: In Compile time polymorphism or Early Binding we will use multiple methods with same name but different type of parameter or may be the number or parameter because of this we can perform different-different tasks with same method name in the same class which is also known as Method overloading.

RunTime Polymorphism or Late Binding: Runtime polymorphism also known as late binding, in Run Time polymorphism or Late Binding we can do use same method names with same signatures means same type or same number of parameters but not in same class because compiler doesn’t allowed that at compile time so we can use in derived class that bind at run time when a child class or derived class object will instantiated that’s way we says that Late Binding.

32
Q

What are the differences between IEnumerable and IQueryable?

A

The IQueryable interface inherits the IEnumerable interface so that if it represents a query, the results of that query can be enumerated.

Enumeration causes the expression tree associated with an IQueryable object to be executed. The definition of “executing an expression tree” is specific to a query provider. For example, it may involve translating the expression tree to an appropriate query language for the underlying data source. Queries that do not return enumerable results are executed when the Execute method is called.

Use IEnumerable when:
You are working with in-memory collections.
The dataset is relatively small and can be loaded into memory without performance issues.

Use IQueryable when:
You need to query against a database or another external data source.
You want to leverage the capabilities of LINQ to construct complex queries that can be executed efficiently on the data source.

33
Q

IEnumerable

A

IEnumerable pozwala na iterację po elementach kolekcji tylko w jednym kierunku – od pierwszego elementu do ostatniego.

Zapytania LINQ, które zwracają IEnumerable, są wykonywane dopiero w momencie ich użycia (np. przez ToList() lub iterację w pętli).

Do iteracji używany jest foreach.

IEnumerable jest używane wyłącznie do odczytu danych. Aby modyfikować kolekcję, musisz korzystać z jej konkretnej implementacji, np. List<T>.</T>

IEnumerable udostępnia metodę GetEnumerator, która pozwala uzyskać obiekt implementujący interfejs IEnumerator, umożliwiając iterację po kolekcji.

34
Q

IQueryable

A

As per MSDN IQueryable interface is intended for implementation by query providers. It is only supposed to be implemented by providers that also implement IQueryable.

-Work with database data

IQueryable umożliwia wykonywanie leniwych (lazy) zapytań, co oznacza, że dane nie są pobierane z bazy aż do faktycznego użycia wyników (np. przez ToList() lub FirstOrDefault()).

IQueryable<Person> query = context.People.Where(p => p.Age > 30);</Person>

// Zapytanie jest wykonane dopiero tutaj
var results = query.ToList();

IQueryable przenosi operacje LINQ do bazy danych (lub innego źródła danych), a nie wykonuje ich w pamięci. Dzięki temu zapytania są optymalizowane przez dostawcę (np. SQL Server).

IQueryable jest idealne, gdy pracujesz z różnymi dostawcami danych, które obsługują LINQ (np. Entity Framework, LINQ to SQL, LINQ to Entities).

IQueryable<Person> query = context.People
.Where(p => p.Name.Contains("John"))
.OrderBy(p => p.Age)
.Take(10);</Person>

// Całość jest przetwarzana w SQL
var top10 = query.ToList();

35
Q

What happens if the inherited interfaces have conflicting method names?

A

If we implement multiple interface in the same class with conflict method name so we don’t need to define all or in other words we can say if we have conflict methods in same class so we can’t implement their body independently in the same class coz of same name and same signature so we have to use interface name before method name to remove this method confiscation

36
Q

What are the Arrays in C#.Net?

A

So in this situation Arrays provide mechanisms that solves problem posed by these questions. An array is a collection of related items, either value or reference type. In C# arrays are immutable such that the number of dimensions and size of the array are fixed.

  • The length cannot be changed once created.
  • Elements are initialized to default values.
  • Arrays are reference types and are instances of System.Array.
  • Their number of dimensions or ranks can be determined by the Rank property.
  • An array length can be determined by the GetLength() method or Length property.
37
Q

What is the Constructor Chaining in C#?

A

Constructor Chaining is a way to connect two or more classes in a relationship as Inheritance
in Constructor Chaining every child class constructor is mapped to parent class Constructor implicitly by base keyword so when you create an instance of child class to it’ll call parent’s class Constructor without it inheritance is not possible.

// Constructor with two parameters
public Person(string name, int age)
{
Name = name;
Age = age;
}

// Constructor with one parameter calling the two-parameter constructor
public Person(string name) : this(name, 0) // Default age to 0
{
}

// Parameterless constructor calling the one-parameter constructor
public Person() : this(“Unknown”) // Default name to “Unknown”
{
}

38
Q

What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?

A

Clone - Method creates a shallow copy of an array. A shallow copy of an Array copies only the elements of the Array, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new Array point to the same objects that the references in the original Array point to.

Clone() is used to create a new array that is a shallow copy of the current array.
_______________________________________________________
CopyTo - The Copy static method of the Array class copies a section of an array to another array. The CopyTo method copies all the elements of an array to another one-dimension array. The code listed in Listing 9 copies contents of an integer array to an array of object types.

CopyTo() is used to copy the elements of one array to another existing array.

array.CopyTo(destinationArray, destinationIndex);

Performs a shallow copy of the elements from the source array to the destination array.

39
Q

Can Multiple Catch Blocks executed in c#?

A

Yes, Like others said the exception will be caught by the most specific catch block.

try
{
// blah blah blah
{
catch(Arithmetic ae)
{
HandleArithmeticException( ae );
HandleGenericException( ae );
}
catch(Exception e)
{
HandleGenericException( e );
}

40
Q

Difference between Throw Exception and Throw Clause.

A

The basic difference is that the Throw exception overwrites the stack trace and this makes it hard to find the original code line number that has thrown the exception.

Throw basically retains the stack information and adds to the stack information in the exception that it is thrown.

THROW IS BETTER BECAUSE IT DOESNT OVERWRITES THE STACK TRACE

41
Q

What is Indexer in C# .Net?

A

Indexer allows classes to be used in more intuitive manner. C# introduces a new concept known as Indexers which are used for treating an object as an array. The indexers are usually known as smart arrays in C#. They are not essential part of object-oriented programming.

TREATING OBJECT AS AN ARRAY

An indexer, also called an indexed property, is a class property that allows you to access a member variable of a class using the features of an array.

public string this[int index]
get{
if (index >= 0 && index < dni.Length)
{
return dni[index];
}
}
set{}

42
Q

What is multicast delegate in c#?

A

A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.

Delegate can invoke only one method reference has been encapsulated into the delegate.it is possible for certain delegate to hold and invoke multiple methods such delegate called multicast delegates.multicast delegates also know as combinable delegates, must satisfy the following conditions:

  • The return type of the delegate must be void. None of the parameters of the delegate type can be delegate type can be declared as output parameters using out keywords.
  • Multicast delegate instance that created by combining two delegates, the invocation list is formed by concatenating the invocation list of two operand of the addition operation. Delegates are invoked in the order they are added.
43
Q

Difference between Equality Operator (==) and Equals() Method in C#.

A

== porównuje czy referencja do obiektu jest taka sama

podczas gdy Equals() porównuje czy zawartość jest taka sama.

_____________________________________________________

The Equality Operator (==) is the comparison operator and the Equals() method compares the contents of a string.

The == Operator compares the reference identity while the Equals() method compares only contents.

The == operator is used to compare values or references, depending on the types being compared. Its behavior can vary based on how it is defined for a particular type.
-> When comparing value types (e.g., int, double, structs), == compares the actual values.
-> When comparing reference types (e.g., objects, arrays, classes), the default behavior of == is to compare object references (memory addresses),
______________________________________________________
Equals()

Compares references for reference types, unless overridden to compare values

Equals() method compares references for reference types, similar to the == operator for objects, but it can be overridden to compare values.

44
Q

Difference between “is” and “as” operator in C#.

A

“is” operator- In the C# language, we use the “is” operator to check the object type. If the two objects are of the same type, it returns true and false if not.

is performs type checking but does not cast the object to the specified type.

RETURNS TRUE/FALSE
________________________________________________________
“as” operator

The as operator attempts to cast an object to a specified type. If the cast is successful, it returns the object as the new type; if not, it returns null.

COVNERTS, RETURNS OBJECT OR NULL

The “as” operator behaves similar to the “is” operator. The only difference is it returns the object if both are compatible to that type else it returns null.

45
Q

How to use Nullable<> Types in .Net?

A

A nullable Type is a data type that contain the defined data type or the value of null.

You should note here that here variable datatype has been given and then only it can be used.

This nullable type concept is not compatible with “var”.

NOT VAR

46
Q

Different Ways of Method can be overloaded.

A

Method overloading is a way to achieve compile time Polymorphism where we can use a method with the same name but different signature,

Method overloading is done at compile time and we have multiple way to do that but in all way method name should be same.

Number of parameter can be different.

Types of parameter can be different.

Order of parameters can be different.

COMPILE TIME!

47
Q

What is an Object Pool in .Net?

A

Object Pooling is something that tries to keep a pool of objects in memory to be re-used later and hence it will reduce the load of object creation to a great extent.

What does it mean?

Object Pool is nothing but a container of objects that are ready for use.

Whenever there is a request for a new object, the pool manager will take the request and it will be served by allocating an object from the pool.

48
Q

Paramter in

A

Parametr in oznacza, że przekazujemy zmienną do metody przez referencję, ale metoda nie może zmieniać wartości tego parametru.

Parametr in używany jest głównie z typami wartościowymi (np. struct), gdzie koszt kopiowania dużych struktur może być wysoki. Przekazanie przez referencję pozwala uniknąć kopiowania, ale gwarantuje, że przekazana wartość pozostanie niezmieniona.

49
Q

Porównanie in vs ref vs out

A

Modyfikacja wartości wewnątrz metody:

-in: Parametr nie może być modyfikowany wewnątrz metody.

-ref: Parametr może być modyfikowany wewnątrz metody.

-out: Parametr musi być przypisany wewnątrz metody, ale może być modyfikowany.

Wartość początkowa zmiennej:

-in: Zmienna przekazana przez in musi mieć
przypisaną wartość przed wywołaniem metody.

-ref: Zmienna przekazana przez ref musi mieć przypisaną wartość przed wywołaniem metody.

-out: Zmienna przekazana przez out nie musi mieć przypisanej wartości przed wywołaniem metody, ale musi być przypisana wewnątrz metody.

Zastosowanie:
-in: Używany, gdy chcemy przekazać duże struktury danych (np. struct), bez kopiowania, ale bez możliwości modyfikacji.

-ref: Używany, gdy chcemy przekazać zmienną do modyfikacji.

-out: Używany, gdy metoda powinna zwrócić wynik przez parametr.