-
[C#] What is C#?
C# is an object-oriented programming language compiled by the .Net framework to generate Microsoft Intermediate Language.
-
[C#] What is the difference between static, public, and void?
- Public declared variables can be accessed from anywhere in the application.
- Static declared variables can be accessed globally without needing to create an instance of the class.
- Void is a type modifier which states the method and is used to specify the return type of a method in C#.
-
[C#] What is an object?
An object is a class instance that can be used to access class methods. The "new" keyword can be used to construct an object.
-
[C#] Define constructors.
A constructor is a member function with the same name as its class. The constructor is automatically invoked when an object is created. While the class is being initialized, it constructs all the values of the data members.
-
[C#] What are Jagged Arrays?
The Array which comprises elements of type array is called Jagged Array. The elements in Jagged Arrays can be of various dimensions and sizes.
-
[C#] What is the difference between out and ref parameters?
-When an argument is passed as a ref, it must be initialized before it can be passed to the method.
-An out parameter, on the other hand, need not to be initialized before passing to a method.
-
[C#] What is Serialization?
In order to transport an object through a network, we would need to convert it into a stream of bytes. This process is called Serialization.
-
[C#] What is the benefit of ‘using’ statement in C#?
The ‘using’ statement can be used in order to obtain a resource for processing before automatically disposing it when execution is completed.
-
[C#] Can “this” command be used within a static method ?
No. This is because only static variables/methods can be used in a static method.
-
[C#] Differentiate between break and continue Statement.
- Continue statement - Used in jumping over a particular iteration and getting into the next iteration of the loop.
- Break statement - Used to skip the next statements of the current iteration and come out of the loop.
-
[C#] List the access modifiers:
private, public, internal, protected
-
[C#] Access Modifiers: private
A private attribute or method is one that can only be accessed from within the class.
-
[C#] Access Modifiers: public
When an attribute or method is declared public, it can be accessed from anywhere in the code.
-
[C#] Access Modifiers: internal
When a property or method is defined as internal, it can only be accessible from the current assembly point of that class.
-
[C#] Access Modifiers: protected
When a user declares a method or attribute as protected, it can only be accessed by members of that class and those who inherit it.
-
[C#] Brief rundown of C# features
- • C# is a safely typed and managed language.
- • C# is object-oriented in nature.
- • C# is a Cross-platform friendly language.
- • C# is a platform-independent language when it comes to compilation.
- • C# is general purpose in nature.
- • C# is used in implementing Destructors and Constructors.
- • C# is part of the .NET framework.
- • C# is an easy-to-learn and easy-to-grasp language.
- • C# is a structured language.
-
[C#] What is meant by Unmanaged or Managed code?
1) managed code is code that is executed by the CLR (Common Language Runtime). This means that every application code is totally dependent on the .NET platform and is regarded as overseen in light of it.
2) unmanaged code is code executed by a runtime program that is not part of the .NET platform. Memory, security, and other activities related to execution will be handled by the application's runtime.
-
[C#] What is meant by an Abstract Class?
It's a type of class whose objects can't be instantiated, and it's signified by the term 'abstract'. It consists of a methodology or a single approach.
-
[C#] What is meant by an Interface?
An interface is a class that does not have any implementation. Only the declarations of events, properties, and attributes are included.
-
[C#] Differentiate between finalize blocks and finalize.
1) Once the try and catch blocks have been completed, the finalize block is called since it is used for exception handling. No matter if the exception has been captured, this block of code is run. In general, the code in this block is cleaner.
2) Just before garbage collection, the finalize method is called. The main priorities of the finalize method are to clean up unmanaged code, which is automatically triggered whenever an instance is not re-called.
-
[C#] REFERENCE TYPES vs VALUE TYPES: REFERENCE TYPES.
Reference types:
Include classes, interfaces, delegates, and strings.
Do not contain data directly but only refer to data.
Allocated on the heap.
Variables of reference types store references to data, called objects.
Allocated on the managed heap and eventually get destroyed via garbage collection.
-
[C#] REFERENCE TYPES vs VALUE TYPES: VALUE TYPES
Value types:
Include the simple types like int and decimal, in addition to structures, and enumeration types.
Allocated on the stack.
Directly contain their own data.
Each variable has its own copy of the data.
-
[C#] What is the difference between read-only and constants?
During the time of compilation, constant variables are declared as well as initialized. It’s not possible to change this particular value later. On the other hand, read-only is used after a value is assigned at run time.
-
[C#] Describe the accessibility modifier “protected internal”.
Variables or methods that are protected internal can be accessed within the same assembly as well as from the classes which have been derived from the parent class.
-
[C#] What is the difference between Arraylist and Array?
An array only has items of the same type and its size if fixed. Arraylist is similar but it does not have a fixed size.
-
[C#] REFERENCE TYPES vs VALUE TYPES: Summarize the key differences between reference types and value types.
Memory storage: Value types store their actual data values directly, while reference types store references to the data.
Assignment behavior: Value types are copied when assigned to a new variable, whereas reference types copy the reference (memory address) to the data.
Copying behavior: Modifying a copy of a value type does not affect the original value, while modifying a copy of a reference type affects the original data.
Nullability: Value types cannot be null unless they are nullable value types (e.g., int?), whereas reference types can be null.
Default values: Value types have default values even if not explicitly initialized, while reference types default to null if not initialized.
-
[C#] What’s the difference between an abstract and interface class?
-All methods in interfaces have only a declaration but no definition. We can have some strong methods in an abstract class.
-All methods in an interface class are public-- private methods may exist in an abstract class.
|
|