Introduction (C#) Flashcards
What is .Net?
It is a runtime similar to Java that executes Microsoft intermediate language (MSIL) at runtime.
What are the three file types in a .Net project?
- Solution files (.sln).
- CS project files (.csproj).
- Code files (.cs).
What does solution files contain?
They contain a set of project files in a .Net project.
What are CS project files and what do they contain?
- They are the smallest buildable unit in a .Net project and they are build into a DLL or executable file (EXE file).
- They can contain dependencies to other projects and build information (ant/make style).
What do CS project files contain?
They contain C# code and belong to a C# project (.csproj).
What is the style convention for methods in a .Net project?
Methods are always capitalized and uses the PascalCase.
What is the style convention for variables in a .Net project?
Variables use camelCase.
What are namespaces?
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.
Does package-scoped classes and methods exist in a .Net project?
No.
What is the difference between a namespace and a package in a .Net project?
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.
What does it mean when a public sealed class in a .Net project?
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.
What does it mean when a final class is “sealed” and a final variable is “readOnly” in a .NET project?
- 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.
- 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.
What does the keyword “internal” mean?
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.
What are override methods annotated as?
They are annotated as abstract, virtual or override.
What are the differences in type names between Java and C#?
boolean is bool.
String is string.
Object is object.
List is IList.
HashMap is Dictionary.
What is the difference in comparing strings between Java and C#?
In C#, strings can be compared using “ == “, while in Java you need to use the “equalsTo( )” method.
What is the difference in numeric types between Java and C#?
In C#, numeric types have unsigned variants:
byte (-128..127).
ubyte (0..255).
uint (0..2^(32)-1).
ulong (0..2^(64)-1).
What are some differences between generics in Java and C#?
Generics in C# are less fiddly as they are both a compile-time and run-time concept.
What are Properties in a .Net project?
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.
How are Properties different from fields in a .Net project?
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.
What is the syntax for accessing a Property in .Net?
They can be accessed using syntax similar to accessing a field, such as “ int x = aClass.Value “.