Introduction (C#) Flashcards

1
Q

What is .Net?

A

It is a runtime similar to Java that executes Microsoft intermediate language (MSIL) at runtime.

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

What are the three file types in a .Net project?

A
  1. Solution files (.sln).
  2. CS project files (.csproj).
  3. Code files (.cs).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does solution files contain?

A

They contain a set of project files in a .Net project.

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

What are CS project files and what do they contain?

A
  1. They are the smallest buildable unit in a .Net project and they are build into a DLL or executable file (EXE file).
  2. They can contain dependencies to other projects and build information (ant/make style).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What do CS project files contain?

A

They contain C# code and belong to a C# project (.csproj).

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

What is the style convention for methods in a .Net project?

A

Methods are always capitalized and uses the PascalCase.

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

What is the style convention for variables in a .Net project?

A

Variables use camelCase.

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

What are namespaces?

A

They are used to organize and group related classes and other types of code.

It is like a container that holds a collection of related classes, structures, and other types.

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

Does package-scoped classes and methods exist in a .Net project?

A

No.

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

What is the difference between a namespace and a package in a .Net project?

A

Namespaces are like a container that holds a collection of related classes, structures, and other types. It helps to organize code and avoid naming conflicts.

On the other hand, a package in Java is a collection of related classes and interfaces that are used to organize code and to provide a level of access protection and name-spacing.

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

What does it mean when a public sealed class in a .Net project?

A

The keyword “sealed” is used to indicate that a class cannot be inherited or subclassed, similar to the “final” keyword in Java.

A public sealed class cannot be extended by other classes, and any attempts to do so will result in a compilation error.

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

What does it mean when a final class is “sealed” and a final variable is “readOnly” in a .NET project?

A
  1. Once a class is “sealed”, it cannot be inherited by any other class. This means that no further functionality can be added to the class by extending it.
  2. Once a readonly variable is initialized, its value cannot be changed. This is useful for values that should not change during runtime, such as configuration settings or constants.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the keyword “internal” mean?

A

It means that any class, method, or variable marked as internal can be accessed within the entire project, but not from outside the project or from other assemblies.

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

What are override methods annotated as?

A

They are annotated as abstract, virtual or override.

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

What are the differences in type names between Java and C#?

A

boolean is bool.
String is string.
Object is object.
List is IList.
HashMap is Dictionary.

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

What is the difference in comparing strings between Java and C#?

A

In C#, strings can be compared using “ == “, while in Java you need to use the “equalsTo( )” method.

17
Q

What is the difference in numeric types between Java and C#?

A

In C#, numeric types have unsigned variants:
byte (-128..127).
ubyte (0..255).
uint (0..2^(32)-1).
ulong (0..2^(64)-1).

18
Q

What are some differences between generics in Java and C#?

A

Generics in C# are less fiddly as they are both a compile-time and run-time concept.

19
Q

What are Properties in a .Net project?

A

They are a way to define values for a class that can be accessed and modified from the outside. They are like variables or fields, but with additional functionality that allows you to control access and modification of their values.

20
Q

How are Properties different from fields in a .Net project?

A

They provide a way to encapsulate data, whereas fields are just variables that hold data. Properties can have validation, computed values, or other logic associated with them, while fields do not.

21
Q

What is the syntax for accessing a Property in .Net?

A

They can be accessed using syntax similar to accessing a field, such as “ int x = aClass.Value “.