INTERVIEW QUESTIONS

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Managed Code

"The code, which is developed in .NET framework is known as managed code. This code is directly executed by CLR with the help of managed code execution. Any language that is written in .NET Framework is managed code".

Advantages of LINQ

1. LINQ offers an object-based, language-integrated way to query over data no matter where that data came from. So through LINQ we can query database, XML as well as collections. 2. Compile time syntax checking. 3. It allows you to query collections like arrays, enumerable classes etc in the native language of your application, like VB or C# in much the same way as you would query a database using SQL.

Explain Hashtable in C#?

A Hashtable is a collection that stores (Keys, Values) pairs. Here, the Keys are used to find the storage location and is immutable and cannot have duplicate entries in the Hashtable. The .Net Framework has provided a Hash Table class that contains all the functionality required to implement a hash table without any additional development. The hash table is a general-purpose dictionary collection. Each item within the collection is a DictionaryEntry object with two properties: a key object and a value object. These are known as Key/Value. When items are added to a hash table, a hash code is generated automatically. This code is hidden from the developer. All access to the table's values is achieved using the key object for identification. As the items in the collection are sorted according to the hidden hash code, the items should be considered to be randomly ordered.

What is a constructor?

A constructor is a class member executed when an instance of the class is created. The constructor has the same name as the class, and it can be overloaded via different signatures. Constructors are used for initialization chores.

Array

A data structure that contains a group of elements. Typically these elements are all the same data type (ex: String or int). Used to organize data so that related sets of values can be easily sorted and searched.

What is jagged array in C#.Net?

A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays." A special type of array is introduced in C#. A Jagged Array is an array of an array in which the length of each array index can differ.

method

A method (or message) in object-oriented programming (OOP) is a procedure associated with an object. An object is made up of data and behavior, which form the interface that an object presents to the outside world. Data is represented as properties of the object and behavior as methods. In class-based programming, methods are defined in a class, and objects are instances of a given class. One of the most important capabilities that a method provides is method overriding. Method in Java programming sets the behaviour of class object. Methods also provide the interface that other classes use to access and modify the data properties of an object.

Namespaces

A namespace is a group of related elements that each have a unique name or identifier. There are several different types of namespaces, and each one has a specific syntax used to define the corresponding elements. Each element within a namespace has a "local name" that serves as a unique identifier. Namespaces are used in many areas of computing, such as domain names, file paths, and XML documents. Below are examples of these different applications. In computing, a namespace is a set of symbols that are used to organize objects of various kinds, so that these objects may be referred to by name. Prominent examples include: file systems are namespaces that assign names to files;[1] programming languages organize their variables and subroutines in namespaces;[2][better source needed] computer networks and distributed systems assign names to resources, such as computers, printers, websites, (remote) files, etc. Namespaces are commonly structured as hierarchies to allow reuse of names in different contexts. As an analogy, consider a system of naming of people where each person has a proper name, as well as a family name shared with their relatives. If, in each family, the names of family members are unique, then each person can be uniquely identified by the combination of first name and family name; there is only one Jane Doe, though there may be many Janes. Within the namespace of the Doe family, just "Jane" suffices to unambiguously designate this person, while within the "global" namespace of all people, the full name must be used. In a similar way, hierarchical file systems organize files in directories. Each directory is a separate namespace, so that the directories "letters" and "invoices" may both contain a file "to_jane". In computer programming, namespaces are typically employed for the purpose of grouping symbols and identifiers around a particular functionality and to avoid name collisions between multiple identifiers that share the same name.

How to use Nullable<> Types in .Net?

A nullable Type is a data type is 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 comaptible with "var". Any DataType can be declared nullable type with the help of operator "?".

What are partial classes?

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 all the class name which you want to bind together with the same name of class in same namespace

Properties

A property, in some object-oriented programming languages, is a special sort of class member, intermediate between a field (or data member) and a method. Properties are read and written like fields, but property reads and writes are (usually) translated to get and set method calls. The field-like syntax is said to be easier to read and write than lots of method calls, yet the interposition of method calls allows for data validation, active updating (as of GUI visuals), or read-only 'fields'. That is, properties are intermediate between member code (methods) and member data (instance variables) of the class, and properties provide a higher level of encapsulation than public fields.

What is a singleton?

A singleton is a design pattern used when only one instance of an object is created and shared; that is, it only allows one instance of itself to be created. Any attempt to create another instance simply returns a reference to the first one. Singleton classes are created by defining all class constructors as private. In addition, a private static member is created as the same type of the class, along with a public static member that returns an instance of the class.

static/class initializer

A static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated. In other words, you cannot use the new keyword to create a variable of the class type. Because there is no instance variable, you access the members of a static class by using the class name itself.

Strings

A string is a data type used in programming, such as an integer and floating point unit, but is used to represent text rather than numbers. It is comprised of a set of characters that can also contain spaces and numbers. For example, the word "hamburger" and the phrase "I ate 3 hamburgers" are both strings. Even "12345" could be considered a string, if specified correctly. Typically, programmers must enclose strings in quotation marks for the data to recognized as a string and not a number or variable name. One of the most widely used data types is a string. A string consists of one or more characters, which can include letters, numbers, or other types of characters. You can think of a string as plain text. A string represents alphanumeric data. This means that a string can contain many different characters, but they are all considered as if they were text, even if the characters are numbers. A string can also contain spaces. This presents a bit of an issue. How are you going to distinguish between the value of a string and the actual code of the program? The solution is to mark the beginning and end of a string with a special character, typically a quote.

Operators

An operator in a programming language is a symbol that tells the compiler or interpreter to perform specific mathematical, relational or logical operation and produce final result. This chapter will explain the concept of operators and it will take you through the important arithmetic and relational operators available in C, Java, and Python. Assignment operators: Assign the value on its right to the operand on its left. It is denoted by the symbol "=". The assignment operator statement has the syntax as shown below: int distance = 0 int radius = 2 Arithmetic operators: There are eight arithmetic operators available in Java. They perform addition, subtraction, multiplication, division, modulo (or remainder), increment (or add 1), decrement (or subtract 1), and negation. + Additive operator (also used for String concatenation) -Subtraction operator * Multiplication operator / Division operator % remainder operator Relational Operators: The relational operators are used to compare 2 or more objects. There are six relational operators in Java: == equal to != not equal to >> greater than >= greater than or equal to < less than <= less than or equal to Logical operators: The logical operators return a true or false value according to the state of the variables. Java provides six logical operators: AND, OR, Conditional OR, exclusive OR, and NOT. Bitwise operators: Manipulate the contents of variables at the bit level. The data type of these variables must be numeric (char, int, long, short). There are seven bitwise operators. They are AND, OR, Exclusive-OR, compliment, Left-shift, Signed Right-Shift, and Unsigned Right-shift. Compound operators: Are used when shortcuts need to be performed in programming operations. There are eleven compound assignment operators in java. The syntax for compound operators is: argument 1 operator = argument2. Conditional operators: The conditional operator is the only operator that takes three arguments in Java. The conditional operator is equivalent to if-else statement. The operators are: && conditional- AND | |-conditional-OR The operator first assesses the first argument and if that is true, it assesses the next argument. If the first becomes false, then the control moves to the third argument. Type comparison operators: The instanceof operator compares an object to a specified type. This operator can be used to test if an object is an instance of a class, subclass or a particular interface.

Explain Anonymous type in C#?

Anonymous types allow us to create new type without defining them. This is way to defining read only properties into a single object without having to define type explicitly. Here Type is generating by the compiler and it is accessible only for the current block of code. The type of properties is also inferred by the compiler. We can create anonymous types by using "new" keyword together with the object initializer.

Hashing

Hashing is generating a value or values from a string of text using a mathematical function. Hashing is one way to enable security during the process of message transmission when the message is intended for a particular recipient only. A formula generates the hash, which helps to protect the security of the transmission from unauthorized users. Hashing is also a method of sorting key values in a database table in an efficient manner. When a user sends a secure message, a hash of the intended message is generated and encrypted and sent along with the message. When the message is received, the receiver decrypts the hash as well as the message. Then, the receiver creates another hash from the message. If the two hashes are similar when compared, then a secure transmission has occurred. This hashing process ensures that the message is not intercepted or viewed by an unauthorized end user. Hashing is used to index and retrieve items in a database because it is easier to find the item using the shortened hashed key than using the original value.

Attributes

In computing, an attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such. For clarity, attributes should more correctly be considered metadata. An attribute is frequently and generally a property of a property. However, in actual usage, the term attribute can and is often treated as equivalent to a property depending on the technology being discussed. An attribute of an object usually consists of a name and a value; of an element, a type or class name; of a file, a name and extension.

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<T> which a parent interface of all generic collections class in System.Collections.Generic namespace like List<> and more.

What is LINQ in C#?

LINQ stands for Language Integrated Query. LINQ is a data querying methodology which provides querying capabilities to .NET languages with a syntax similar to a SQL query LINQ has a great power of querying on any source of data. The data source could be collections of objects, database or XML files. We can easily retrieve data from any object that implements the IEnumerable<T> interface.

Data types

Programming uses a number of different data types. A data type determines what type of values an object can have and what operations can be performed. he second most important data type is numeric data. There are several different ones. An integer is a numeric value without a decimal. Integers are whole numbers and can be positive or negative. Sometimes a distinction is made between short and long integers, referring to how much data storage is used for the number. A short integer is typically stored using 16 bits, which means you can store up to 2^16, or 65,536, unique values. For any numbers larger than that, you would need to use a long integer, which uses 32 bits or more. A number with a decimal is referred to as a decimal, a float or a double. The terminology varies somewhat with the programming language being used. The term 'float' comes from floating point, which means you can control where the decimal point is located. The term 'double' refers to using double the amount of storage relative to a float. Working with numbers in code is a little bit like using a calculator. The Boolean data type can only represent two values: true or false. Typically, a 1 is used to represent True, and a 0 is used to represent False. Consider the following example where a user inputs two values and the program determines whether the first one is smaller than the second one or not. The data types covered so far are often referred to as primitive data types. A composite data type is obtained by combining more than one primitive data type. These are also referred to as data structures. Common examples of composite data types are lists and arrays. A list contains elements of one particular data type. For example, a list could contain strings. An example would be the names of all players on a soccer team. Each name is a string, but when you organize all the names together, they form a list. A list is the simplest data structure.

What is Reflection in C#.Net?

Reflection typically is the process of runtime type discovery to inspect metadata, CIL code, late binding and self-generating code. At run time by using reflection, we can access the same "type" information as displayed by the ildasm utility at design time. The reflection is analogous to reverse engineering in which we can break an existing *.exe or *.dll assembly to explore defined significant contents information, including methods, fields, events and properties. You can dynamically discover the set of interfaces supported by a given type using the System.Reflection namespace.

What is File Handling in C#.Net?

The System.IO namespace provides four classes that allow you to manipulate individual files, as well as interact with a machine directory structure. The Directory and File directly extends System.Object and supports the creation, copying, moving and deletion of files using various static methods. They only contain static methods and are never instantiated. The FileInfo and DirecotryInfo types are derived from the abstract class FileSystemInfo type and they are typically, employed for obtaining the full details of a file or directory because their members tend to return strongly typed objects. They implement roughly the same public methods as a Directory and a File but they are stateful and the members of these classes are not static.

What is Multithreading with .NET?

The real usage of a thread is not about a single sequential thread, but rather using multiple threads in a single program. Multiple threads running at the same time and performing various tasks is referred as Multithreading. A thread is considered to be a lightweight process because it runs within the context of a program and takes advantage of resources allocated for that program.

Reference Type With Value Type

Contrary to the above case, in this scenario, both Reference & Value Types will be effected. I.e. a Value Type member in a Reference Type will be shared among its instances.

What are generics in c#.net?

Generics allow you to delay the specification of the data type of programming elements in a class or a method, until it is actually used in the program. In other words, generics allow you to write a class or method that can work with any data type. You write the specifications for the class or the method, with substitute parameters for data types. When the compiler encounters a constructor for the class or a function call for the method, it generates code to handle the specific data type.

Pure Value Type

Here I used a structure as a value type. It has an integer member. I created two instances of this structure. After wards I assigned second instance to the first one. Then I changed the state of second instance, but it hasn't effect the first one, as whole items are value type and assignments on those types will copy only values not references i.e. in a Value Type assignment, all instances have its own local copy of members.

Different Ways of Method can be overloaded

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.

How are methods overloaded?

Methods are overloaded via different signatures (number of parameters and types). Thus, you can overload a method by having different data types, different number of parameters, or a different order of parameters.

How do you initiate a string without escaping each backslash?

You put an @ sign in front of the double-quoted string. String ex = @"This has a carriage return\r\n"

What is C#?

C# is the best language for writing Microsoft .NET applications. C# provides the rapid application development found in Visual Basic with the power of C++. Its syntax is similar to C++ syntax and meets 100% of the requirements of OOPs like the following:

Difference between is and as operator in C#.

"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. "as" operator: 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.

superclass or base class

(Or "superclass") The class from which another class (a "subclass") inherits, the class it is based on. "base class" is the term used in C++. The objects of the superclass are a superset of the objects of the subclass. n the relationship between two objects a superclass is the name given to the class that is being inherited from. It sounds like it's a super duper class but remember that it's the more generic version. Better names to use might be base class or simply parent class. To take a more real world example this time we could have a superclass called "Person". Its state holds the person's name, address, height and weight and has behaviors like go shopping, make the bed, and watch TV. We could make two new classes that inherit from Person called "Student" and "Worker". They are more specialized versions because although they have names, addresses, watch TV and go shopping, they also have characteristics that are different from each other. Worker could have a state that holds a job title and place of employment whereas Student might hold data on an area of study and an institution of learning.

There are three types of serialization:

1. Binary serialization (Save your object data into binary format). 2. Soap Serialization (Save your object data into binary format; mainly used in network related communication). 3. XmlSerialization (Save your object data into an XML file).

In C# there are 5 different types of Access Modifiers.

1. public: there are no restrictions in accessing public members 2. private: Access is limited to within the class definition. this is the default access modifier type if none is formally specified 3. protected: Access is limited to within the class definition and any class that inherits from the class 4. internal: Access is limited exclusively to classes defined within the current project assembly 5. protected internal: Access is limited to the current assembly

What is Singleton Design Patterns and How to implement in C#?

1.Ensures a class has only one instance and provides a global point of access to it. 2.A singleton is a class that only allows a single instance of itself to be created, and usually gives simple access to that instance. 3.Most commonly, singletons don't allow any parameters to be specified when creating the instance, since a second request of an instance with a different parameter could be problematic! (If the same instance should be accessed for all requests with the same parameter then the factory pattern is more appropriate.) 4.There are various ways to implement the Singleton Pattern in C#. The following are the common characteristics of a Singleton Pattern. • A single constructor, that is private and parameterless. • The class is sealed. • A static variable that holds a reference to the single created instance, if any. • A public static means of getting the reference to the single created instance, creating one if necessary.

For loop

A "For" Loop is used to repeat a specific block of code a known number of times. For example, if we want to check the grade of every student in the class, we loop from 1 to that number. When the number of times is not known before hand, we use a "While" loop. In computer science a for-loop (or simply for loop) is a control flow statement for specifying iteration, which allows code to be executed repeatedly. The syntax of a for-loop is based on the heritage of the language and the prior programming languages it borrowed from, so programming languages that are descendants of or offshoots of a language that originally provided an iterator will often use the same keyword to name an iterator, e.g., descendants of ALGOL use "for", while descendants of Fortran use "do." There are other possibilities, for example COBOL which uses "PERFORM VARYING".

While loop

A "While" Loop is used to repeat a specific block of code an unknown number of times, until a condition is met. For example, if we want to ask a user for a number between 1 and 10, we don't know how many times the user may enter a larger number, so we keep asking "while the number is not between 1 and 10". If we (or the computer) knows exactly how many times to execute a section of code (such as shuffling a deck of cards) we use a for loop. In most computer programming languages, a while loop is a control flow statement that allows code to be executed repeatedly based on a given boolean condition. The while loop can be thought of as a repeating if statement.

constructor

A constructor is a special method of a class or structure in object-oriented programming that initializes an object of that type. A constructor is an instance method that usually has the same name as the class, and can be used to set the values of the members of an object, either to default or to user-defined values. Constructors are not called explicitly and are invoked only once during their lifetime. In the case of a hierarchy of classes where a derived class inherits from a parent class, the execution sequence of the constructor is a call to the constructor of the parent class first and then that of the derived class. Constructors cannot be inherited. A constructor can be declared using any of the access modifiers. It is mandatory to have a constructor with the right access modifier. However, the compiler supplies a default if an access modifier is not defined in the class. If a constructor is declared as private, the class cannot be created or derived and hence cannot be instantiated. Such a constructor, however, can be overloaded with different sets of parameters.

Foreign key

A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It acts as a cross-reference between tables because it references the primary key of another table, thereby establishing a link between them. The majority of tables in a relational database system adhere to the foreign key concept. In complex databases and data warehouses, data in a domain must be added across multiple tables, thus maintaining a relationship between them. The concept of referential integrity is derived from foreign key theory. Foreign keys and their implementation are more complex than primary keys. For any column acting as a foreign key, a corresponding value should exist in the link table. Special care must be taken while inserting data and removing data from the foreign key column, as a careless deletion or insertion might destroy the relationship between the two tables. For instance, if there are two tables, customer and order, a relationship can be created between them by introducing a foreign key into the order table that refers to the customer ID in the customer table. The customer ID column exists in both customer and order tables. The customer ID in the order table becomes the foreign key, referring to the primary key in the customer table. To insert an entry into the order table, the foreign key constraint must be satisfied. An attempt to enter a customer ID that is not present in the customer table fails, thus maintaining the table's referential integrity. Foreign key constraints are either immediate or deferred. By default, foreign key constraints are immediate. A violation of immediate foreign key constraints throws an exception immediately. Deferred foreign key constraints are reported only during a commit.

Parameter

A parameter is a special kind of variable in computer programming language that is used to pass information between functions or procedures. The actual information passed is called an argument. The rules for how arguments are passed to functions are determined by the programming language and the system. These rules specify whether the arguments will be passed through the stack or machine registers or any other method.It specifies what would be the order of the arguments (from left to right or right to left); whether arguments will be passed by value or by reference etc. Furthermore, in languages such as HL and Haskel, only one argument is allowed per function, these languages, if more than one argument is needed, the argument is passed through multiple functions. In most other languages, multiple parameters can be specified for a single function. The C programming language allows variable number of parameters for a single function.

Primary key

A primary key is a special relational database table column (or combination of columns) designated to uniquely identify all table records. A primary key's main features are: It must contain a unique value for each row of data. It cannot contain null values. A primary key is either an existing table column or a column that is specifically generated by the database according to a defined sequence. The primary key concept is critical to an efficient relational database. Without primary key and closely-related foreign key concepts, relational databases would not work. Almost all individuals deal with primary keys frequently but unknowingly in everyday life. For example, students are routinely assigned unique identification (ID) numbers, and all adults receive government-assigned and uniquely-identifiable Social Security numbers. For example, a database must hold all of the data stored by a commercial bank. Two of the database tables include the CUSTOMER_MASTER, which stores basic and static customer data (e.g., name, date of birth, address and Social Security number, etc.) and the ACCOUNTS_MASTER, which stores various bank account data (e.g., account creation date, account type, withdrawal limits or corresponding account information, etc.). To uniquely identify customers, a column or combination of columns is selected to guarantee that two customers never have the same unique value. Thus, certain columns are immediately eliminated, e.g., surname and date of birth. A good primary key candidate is the column that is designated to hold unique and government-assigned Social Security numbers. However, some account holders (e.g., children) may not have Social Security numbers, and this column's candidacy is eliminated. The next logical option is to use a combination of columns such as the surname to the date of birth to the email address, resulting in a long and cumbersome primary key.

What is Virtual Method in C#?

A virtual method is a method that can be redefined in derived classes. A virtual method has an implementation in a base class as well as derived the class. It is used when a method's basic functionality is the same but sometimes more functionality is needed in the derived class. A virtual method is created in the base class that can be overridden in the derived class. We create a virtual method in the base class using the virtual keyword and that method is overridden in the derived class using the override keyword. When a method is declared as a virtual method in a base class then that method can be defined in a base class and it is optional for the derived class to override that method. The overriding method also provides more than one form for a method. Hence it is also an example for polymorphism. When a method is declared as a virtual method in a base class and that method has the same definition in a derived class then there is no need to override it in the derived class. But when a virtual method has a different definition in the base class and the derived class then there is a need to override it in the derived class. When a virtual method is invoked, the run-time type of the object is checked for an overriding member. The overriding member in the most derived class is called, which might be the original member, if no derived class has overridden the member.

Abstraction

Abstraction is the act of representing essential features without including the background details or explanations. In the computer science and software engineering domain, the abstraction principle is used to reduce complexity and allow efficient design and implementation of complex software systems. Some areas of software design and implementation where the abstraction principle is applied include programming languages (mainly in object-oriented programming languages), specification languages, control abstraction, data abstraction and the architecture of software systems. Abstraction is one of the most important principles in object-oriented software engineering and is closely related to several other important concepts, including encapsulation, inheritance and polymorphism. Abstraction is applied in the process of identifying software artifacts (objects) to model the problem domain. It is the process of reducing these objects to their essence such that only the necessary elements are represented. Abstraction defines an object in terms of its properties, functionality, and interface (means of communicating with other objects). These methods are used to reduce the complexity of the design and implementation process of software. In that process, the designers define abstract object actors that are able to perform work, change their state and communicate with other actors. The state of the object is encapsulated while the detailed data structures associated with the object are kept behind the scenes.

Describe the accessibility modifiers in c#.Net.

Access modifiers are keywords used to specify the declared accessibility of a member or a type. Why to use access modifiers? Access modifiers are an integral part of object-oriented programming. They support the concept of encapsulation, which promotes the idea of hiding functionality. Access modifiers allow you to define who does or doesn't have access to certain features.

What is an Object?

According to MSDN, "a class or struct definition is like a blueprint that specifies what the type can do. An object is basically a block of memory that has been allocated and configured according to the blueprint. A program may create many objects of the same class. Objects are also called instances, and they can be stored in either a named variable or in an array or collection. Client code is the code that uses these variables to call the methods and access the public properties of the object. In an object-oriented language such as C#, a typical program consists of multiple objects interacting dynamically". Objects helps us to access the member of a class or struct either they can be fields, methods or properties, by using the dot.

composition/aggregation

Aggregation is an Association Composition is a strong Association (If the life of contained object totally depends on the container object, it is called strong association) Aggregation is a weak Association (If the life of contained object doesn't depends on the container object, it is called weak association) In computer science, object composition (not to be confused with function composition) is a way to combine simple objects or data types into more complex ones. Compositions are a critical building block of many basic data structures, including the tagged union, the linked list, and the binary tree, as well as the object used in object-oriented programming.[1] In a programming language, when objects are typed, types can often be divided into composite and noncomposite types, and composition can be regarded as a relationship between types: an object of a composite type (e.g. car) "has an" object of a simpler type (e.g. wheel). Aggregation differs from ordinary composition in that it does not imply ownership. In composition, when the owning object is destroyed, so are the contained objects. In aggregation, this is not necessarily true. For example, a university owns various departments (e.g., chemistry), and each department has a number of professors. If the university closes, the departments will no longer exist, but the professors in those departments will continue to exist. Therefore, a University can be seen as a composition of departments, whereas departments have an aggregation of professors. In addition, a Professor could work in more than one department, but a department could not be part of more than one university.

Arrays Overview

An array contains zero or more items called elements. An array is an unordered sequence of elements. All the elements in an array are of the same type (unlike fields in a class that can be of different types). The elements of an array accessed using an integer index that always starts from zero. C# supports single-dimensional (vectors), multidimensional and jagged arrays. Elements are identified by indexes relative to the beginning of the arrays. An index is also commonly called indices or subscripts and are placed inside the indexing operator ([]). Access to array elements is by their index value that ranges from 0 to (length-1).

What is enum in C#?

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. Their 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 to use extension methods?

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 are only in scope when you explicitly import the namespace into your source code with a using directive.

What are the Arrays in C#.Net?

Arrays are powerful data structures for solving many programming problems. You saw during the creation of variables of many types that they have one thing in common, they hold information about a single item, for instance an integer, float and string type and so on. So what is the solution if you need to manipulate sets of items? One solution would be to create a variable for each item in the set but again this leads to a different problem. How many variables do you need? 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.

IQueryable:

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<T>. If the provider does not also implement IQueryable<T>, the standard query operators cannot be used on the provider's data source. 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.

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

Both the == Operator and the Equals() method are used to compare two value type data items or reference type data items. 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. Let's see with some examples. In this example we assigned a string variable to another variable. A string is a reference type and in the following example, a string variable is assigned to another string variable so they are referring to the same identity in the heap and both have the same content so you get True output for both the == Operator and the Equals() method.

What is boxing?

Boxing is the process of explicitly converting a value type into a corresponding reference type. Basically, this involves creating a new object on the heap and placing the value there. Reversing the process is just as easy with unboxing, which converts the value in an object reference on the heap into a corresponding value type on the stack. The unboxing process begins by verifying that the recipient value type is equivalent to the boxed type. If the operation is permitted, the value is copied to the stack.

What is delegates in C# and uses of delegates?

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.

What is DLL Hell, and how does .NET solve it?

DLL Hell describes the difficulty in managing DLLs on a system; this includes multiple copies of a DLL, different versions, and so forth. When a DLL (or assembly) is loaded in .NET, it is loaded by name, version, and certificate. The assembly contains all of this information via its metadata. The GAC provides the solution, as you can have multiple versions of a DLL side-by-side.

What is multicast delegate in c#?

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.

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

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.

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

Extension methods enable you to add methods to existing types without creating a new derived type, 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.

Pure Reference Type

I created a class and added a "DataTable" as a Reference Type member for this class. Then I performed the assignments just like below. But the difference is that on changing the state of second instance, the state of first instance will automatically alter. So in a Reference Type assignment both Value and Reference will be assigned i.e. all instances will point to the single object.

What is IEnumerable<> in c#?

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<T> which a parent interface of all generic collections class in System.Collections.Generic namespace like List<> and more. In System.Collections.Generic.IEnumerable<T> 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.

What happens if the inherited interfaces have conflicting method names?

If we implement multipole 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

Why are strings in C# immutable?

Immutable means string values cannot be changed once they have been created. Any modification to a string value results in a completely new string instance, thus an inefficient use of memory and extraneous garbage collection. The mutable System.Text.StringBuilder class should be used when string values will change.

What is the difference between ref and out keywords?

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 parameter and ref parameter. We have lots of differences in both of them.

What you understand by Value types and Reference types in C#.Net?

In C# data types can be of two types: Value Types and Reference Types. Value type variables contain their object (or data) directly. If we copy one value type variable to another then we are actually making a copy of the object for the second variable. Both of them will independently operate on their values, Value Type member will located into Stack and reference member will located in Heap always.

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.

object

In computer science, an object can be a variable, a data structure, or a function, and as such, is a location in memory having a value and possibly referenced by an identifier. In the class-based object-oriented programming paradigm, "object" refers to a particular instance of a class where the object can be a combination of variables, functions, and data structures.

class

In object-oriented programming, a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods). In many languages, the class name is used as the name for the class (the template itself), the name for the default constructor of the class (a subroutine that creates objects), and as the type of objects generated by instantiating the class; these distinct concepts are easily conflated.

destructor/finalizer

In object-oriented programming, a destructor (dtor) is a method which is automatically invoked when the object is destroyed. It can happen when its lifetime is bound to scope and the execution leaves the scope, when it is embedded in another object which lifetime ends, or when it was allocated dynamically and is released explicitly. Its main purpose is to free the resources (memory allocations, open files or sockets, database connections, resource locks, etc.) which were acquired by the object during its life and/or deregister from other entities which may keep references to it. Use of destructors is needed for the process of Resource Acquisition Is Initialization (RAII). In object-oriented programming, a finalizer or finalize method is a special method that performs finalization, generally some form of cleanup. A finalizer is executed during object destruction, prior to the object being deallocated, and is complementary to an initializer, which is executed during object creation, following allocation. Finalizers are strongly discouraged by many, due to difficulty in proper use and the complexity they add, and alternatives are suggested instead, primarily the dispose pattern[1] - see problems with finalizers. The term "finalizer" is primarily used in object-oriented languages that use garbage collection, of which the archetype is Java. This is contrasted with a "destructor", which is a method called for finalization in languages with deterministic object lifetimes, archetypically C++.[2][3] These are generally exclusive - a language will have either finalizers (if garbage collected) or destructors (if deterministic), but in rare cases a language may have both, as in C++/CLI and D, and in case of reference counting (instead of tracing garbage collection), terminology varies. In technical usage, "finalizer" may also be used to refer to destructors, as these also perform finalization, and some subtler distinctions are drawn - see terminology. For this article, "finalizer" refers only to a method used for finalization in a garbage-collected language; for discussion of finalization generally, see finalization.

interface/protocol

In object-oriented programming, a protocol or interface is a common means for unrelated objects to communicate with each other. These are definitions of methods and values which the objects agree upon in order to co-operate.[1] For example, in Java (where protocols are termed interfaces), the Comparable interface specifies a method compareTo() which implementing classes should implement. This means that a separate sorting method, for example, can sort any object which implements the Comparable interface, without having to know anything about the inner nature of the class (except that two of these objects can be compared by means of compareTo()). The protocol is a description of: The messages that are understood by the object. The arguments that these messages may be supplied with. The types of results that these messages return. The invariants that are preserved despite modifications to the state of an object. The exceptional situations that will be required to be handled by clients to the object.

virtual method

In object-oriented programming, in languages such as C++, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated. This concept is an important part of the (runtime) polymorphism portion of object-oriented programming (OOP).

inheritance

In object-oriented programming, inheritance enables new objects to take on the properties of existing objects. A class that is used as the basis for inheritance is called a superclass or base class. A class that inherits from a superclass is called a subclass or derived class. The terms parent class and child class are also acceptable terms to use respectively. A child inherits visible properties and methods from its parent while adding additional properties and methods of its own. Subclasses and superclasses can be understood in terms of the is a relationship. A subclass is a more specific instance of a superclass. For example, an orange is a citrus fruit, which is a fruit. A shepherd is a dog, which is an animal. A clarinet is a woodwind instrument, which is a musical instrument. If the is a relationship does not exist between a subclass and superclass, you should not use inheritance. An orange is a fruit; so it is okay to write an Orange class that is a subclass of a Fruit class. As a contrast, a kitchen has a sink. It would not make sense to say a kitchen is a sink or that a sink is a kitchen. The has a relationship indicates composition (see Object-oriented programming concepts: Composition and aggregation) rather than inheritance.

class/static method

In object-oriented programming, when a derived class inherits from a base class, an object of the derived class may be referred to via a pointer or reference of the base class type instead of the derived class type. If there are base class methods overridden by the derived class, the method actually called by such a reference or pointer can be bound either 'early' (by the compiler), according to the declared type of the pointer or reference, or 'late' (i.e., by the runtime system of the language), according to the actual type of the object referred to. Virtual functions are resolved 'late'. If the function in question is 'virtual' in the base class, the most-derived class's implementation of the function is called according to the actual type of the object referred to, regardless of the declared type of the pointer or reference. If it is not 'virtual', the method is resolved 'early' and the function called is selected according to the declared type of the pointer or reference. Virtual functions allow a program to call methods that don't necessarily even exist at the moment the code is compiled.

abstract class

In programming languages, an abstract class is a generic class (or type of object) used as a basis for creating specific objects that conform to its protocol, or the set of operations it supports. Abstract classes are not instantiated directly. Abstract classes are useful when creating hierarchies of classes that model reality because they make it possible to specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class (a derived class) is needed. In object-oriented programming (OOP) languages, classes represent objects in the domain of the problem the software is intended to solve. Classes include collections of attributes (properties) and behaviors (methods), which can be based on previously-defined classes. Programmers use inheritance to derive the specific implementation of abstract classes. Classes that are derived from abstract classes are called derived classes. When this principle is applied many times in succession, it results in a hierarchy of classes. In this context, abstract classes are at the root of this hierarchy, and is used to enforce methods that need to be overridden in the derived classes, thus avoiding potential runtime errors. An abstract class has at least one abstract method. An abstract method will not have any code in the base class; the code will be added in its derived classes. The abstract method in the derived class should be implemented with the same access modifier, number and type of argument, and with the same return type as that of the base class. Objects of abstract class type cannot be created, because the code to instantiate an object of the abstract class type will result in a compilation error.

subclass or derived class

In the relationship between two objects a subclass is the name given to the class that is inheriting from the superclass. Although it sounds a little more drab, remember that it's a more specialized version of the superclass. Subclasses can also be known as derived classes or simply child classes. In the previous example, Student and Worker are the subclasses. You can have as many subclasses as you want. There is no limitation to how many subclasses a superclass can have. Likewise there's no limitation on the number of levels of inheritance. A hierarchy of classes can be built upon a certain area of commonality. In fact, if you look at the Java API libraries you will see many examples of inheritance. Every class in the APIs is inherited from a class called java.lang.Object.

What are Indexer in C# .Net?

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. 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. Defining an indexer allows you to create classes that act like virtual arrays. Instances of that class can be accessed using the [] array access operator.

System.Array.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.

method overriding

Method overriding, in object oriented programming, is a language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes. The implementation in the subclass overrides (replaces) the implementation in the superclass by providing a method that has same name, same parameters or signature, and same return type as the method in the parent class.[1] The version of a method that is executed will be determined by the object that is used to invoke it. If an object of a parent class is used to invoke the method, then the version in the parent class will be executed, but if an object of the subclass is used to invoke the method, then the version in the child class will be executed.[2] Some languages allow a programmer to prevent a method from being overridden.

multiple inheritance

Multiple inheritance is a feature of some object-oriented computer programming languages in which an object or class can inherit characteristics and features from more than one parent object or parent class. It is distinct from single inheritance, where an object or class may only inherit from one particular object or class. Multiple inheritance has been a sensitive issue for many years,[1][2] with opponents pointing to its increased complexity and ambiguity in situations such as the "diamond problem", where it may be ambiguous as to which parent class a particular feature is inherited from if more than one parent class implements said feature. This can be addressed in various ways, including using virtual inheritance.[3] Alternate methods of object composition not based on inheritance such as mixins and traits have also been proposed to address the ambiguity.

What are namespaces, and how they are used?

Namespaces are used to organize classes within the .NET Framework. They dictate the logical structure of the code. They are analogous to Java packages, with the key difference being Java packages define the physical layout of source files (directory structure) while .NET namespaces do not. However, many developers follow this approach and organize their C# source files in directories that correlate with namespaces. The .NET Framework has namespaces defined for its many classes, such as System.Xml—these are utilized via the using statement. Namespaces are assigned to classes via the namespace keyword.

Normalization

Normalization is the process of reorganizing data in a database so that it meets two basic requirements: (1) There is no redundancy of data (all data is stored in only one place), and (2) data dependencies are logical (all related data items are stored together). Normalization is important for many reasons, but chiefly because it allows databases to take up as little disk space as possible, resulting in increased performance. Normalization is also known as data normalization. The three main types of normalization are listed below. Note: "NF" refers to "normal form." 1NF 2NF 3NF The following three NFs exist but are rarely used: BCNF 4NF 5NF The first three NFs were derived in the early 1970s by the father of the relational data model, E.F. Codd. Almost all of today's relational database engines use his rules. Some relational database engines do not strictly meet the criteria for all rules of normalization. An example is the multivalued fields feature introduced by Microsoft in the Access 2007 database application. There has been heated debate in database circles as to whether such features now disqualify such applications from being true relational database management systems.

What is an Object Pool in .Net?

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. This article will try to explain this in detail. The example is for an Employee object, but you can make it general by using Object base class. 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. How it works? We are going to use Factory pattern for this purpose. We will have a factory method, which will take care about the creation of objects. Whenever there is a request for a new object, the factory method will look into the object pool (we use Queue object). If there is any object available within the allowed limit, it will return the object (value object), otherwise a new object will be created and give you back.

encapsulation

One of the key concepts of object-oriented programming is that to modify an object's state, one of the object's behaviors must be used. Or to put it another way, to modify the data in one of the object's fields, one of its methods must be called. This is called data encapsulation. By enforcing the idea of data encapsulation on objects we hide the details of how the data is stored. We want objects to be as independent of each other as possible. An object holds data and the ability to manipulate it all in one place. This makes it is easy for us to use that object in more than one Java application. There's no reason why we couldn't take our book class and add it to another application that might also want to hold data about books. In programming, the process of combining elements to create a new entity. For example, a procedure is a type of encapsulation because it combines a series of computer instructions. Likewise, a complex data type, such as a record or class, relies on encapsulation. Object-oriented programming languages rely heavily on encapsulation to create high-level objects. Encapsulation is closely related to abstraction and information hiding. Encapsulation is a strategy used as part of abstraction. Encapsulation refers to the state of objects - objects encapsulate their state and hide it from the outside; outside users of the class interact with it through its methods, but cannot access the classes state directly. So the class abstracts away the implementation details related to its state.

method overloading

Overloading refers to the ability to use a single identifier to define multiple methods of a class that differ in their input and output parameters. Overloaded methods are generally used when they conceptually execute the same task but with a slightly different set of parameters. Overloading is a concept used to avoid redundant code where the same method name is used multiple times but with a different set of parameters. The actual method that gets called during runtime is resolved at compile time, thus avoiding runtime errors. Overloading provides code clarity, eliminates complexity, and enhances runtime performance. Overloading is used in programming languages that enforce type-checking in function calls during compilation. When a method is overloaded, the method chosen will be selected at compile time. This is not the same as virtual functions where the method is defined at runtime. Unlike Java, C# allows operators to be overloaded, in addition to methods, by defining static members using the operator keyword. This feature helps to extend and customize the semantics of operators relevant to user-defined types so that they can be used to manipulate object instances with operators. The overload resolution in C# is the method by which the right function is selected on the basis of arguments passed and the list of candidate function members that have the same name. The different contexts in which the overload resolution is used include: Invocation of a method in an expression Constructor during object creation Indexer accessor through an element access and predefined or user-defined operator expression It is recommended to avoid overloading across inheritance boundaries because it can cause confusion. Overloading can become cumbersome to developers if it is used excessively and with user-defined types as parameters because it can reduce the readability and maintainability of code.

polymorphism

Polymorphism is an object-oriented programming concept that refers to the ability of a variable, function or object to take on multiple forms. A language that features polymorphism allows developers to program in the general rather than program in the specific. In a programming language that exhibits polymorphism, objects of classes belonging to the same hierarchical tree (i.e. inherited from a common base class) may possess functions bearing the same name, but each having different behaviors. As an example, let us assume there is a base class named Animals from which the subclasses Horse, Fish and Bird are derived. Let us also assume that the Animals class has a function named Move, which is inherited by all subclasses mentioned. With polymorphism, each subclass may have its own way of implementing the function. So, for example, when the Move function is called in an object of the Horse class, the function might respond by displaying trotting on the screen. On the other hand, when the same function is called in an object of the Fish class, swimming might be displayed on the screen. In the case of a Bird object, it may be flying. In effect, polymorphism trims down the work of the developer because he can now create a sort of general class with all the attributes and behaviors that he envisions for it. When the time comes for the developer to create more specific subclasses with certain unique attributes and behaviors, the developer can simply alter code in the specific portions where the behaviors will differ. All other portions of the code can be left as is. This definition was written in the context of General Programming

Define Property in C#.net?

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. Now question is what are accessors? 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 publically. We have the three types of properties •Read/Write. •ReadOnly. •WriteOnly

Run Time Polymorphism or Late Binding:

Run time 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. For that we have to create my parent class functions as partial and in driver or child class as override functions with override keyword.

What is sealed class in c#?

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. In C#, the sealed modifier is used to define a class as sealed. In Visual Basic .NET the Not Inheritable keyword serves the purpose of sealed. If a class is derived from a sealed class then the compiler throws an error. If you have ever noticed, structs are sealed. You cannot derive a class from a struct.

What is Serialization?

Serialization means saving the state of your object to secondary memory, such as a file. Suppose you have a business layer where you have many classes to perform your business data. Now suppose you want to test whether your business classes give the correct data out without verifying the result from the UI or from a database. Because it will take some time to process. SO what you will you do my friend? Here comes Serialization. You will serialize all your necessary business classes and save them into a text or XML file. on your hard disk. So you can easily test your desired result by comparing your serialized saved data with. your desired output data. You can say it is a little bit of autonomic unit testing performed by the developer.

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. •It's an immutable object that hold 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.

What is the difference between a struct and a class?

Structs cannot be inherited. Structs are passed by value and not by reference. Structs are stored on the stack not the heap. The result is better performance with Structs.

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. Let's have an example to understand System.Text.Stringbuilder. •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.

What is the use of Using statement in C#?

The .Net Framework provides resource management for managed objects through the garbage collector - You do not have to explicitly allocate and release memory for managed objects. Clean-up operations for any unmanaged resources should performed in the destructor in C#. To allow the programmer to explicitly perform these clean-up activities, objects can provide a Dispose method that can be invoked when the object is no longer needed. The using statement in C# defines a boundary for the object outside of which, the object is automatically destroyed. The using statement is excited when the end of the "using" statement block or the execution exits the "using" statement block indirectly, for example - an exception is thrown. The "using" statement allows you to specify multiple resources in a single statement. The object could also be created outside the "using" statement. The objects specified within the using block must implement the IDisposable interface. The framework invokes the Dispose method of objects specified within the "using" statement when the block is exited.

System.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.

What is the GAC, and where is it located?

The GAC is the Global Assembly Cache. Shared assemblies reside in the GAC; this allows applications to share assemblies instead of having the assembly distributed with each application. Versioning allows multiple assembly versions to exist in the GAC—applications can specify version numbers in the config file. The gacutil command line tool is used to manage the GAC.

What is the execution entry point for a C# console application?

The Main method.

Difference between Throw Exception and Throw Clause.

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. Let us see what it means rather speaking so many words to better understand the differences. I am using a console application to easily test and see how the usage of the two differ in their functionality.

Unmanaged Code

The code, which is developed outside .NET framework is known as unmanaged code. "Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such as C++ can be used to write such applications, which, for example, access low - level functions of the operating system. Background compatibility with the code of VB, ASP and COM are examples of unmanaged code". Unmanaged code can be unmanaged source code and unmanaged compile code. Unmanaged code is executed with the help of wrapper classes.

How do you prevent a class from being inherited?

The sealed keyword prohibits a class from being inherited.

Value Type With Reference Type

This case and the last case to come are more interesting. I used a structure in this particular scenario also. But this time it includes a Reference Type(A Custom Class Object) Member besides a Value Type (An Integer) Member. When you performing the assignments, it seems like a swallow copy, as Value Type member of first instance won't effected, but the Reference Type member will alter according to the second instance. So in this particular scenario, assignment of Reference Type member produced a reference to a single object and assignment of Value Type member produced a local copy of that member.

Unboxing

Unboxing is also a process which is used to extract the value type from the object or any implemented interface type. Boxing may be done implicitly, but unboxing have to be explicit by code.

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

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.

Can "this" be used within a static method?

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#.

What is the Constructor Chaining in C#?

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.

Constant

known as "const" keyword in C# which is also known immutable values which are known at compile time and do not change their values at run time like in any function or constructor for the life of application till the application is running.

Read only

known as "readonly" keyword in C# which is also known immutable values and are known at compile and run time and do not change their values at run time like in any function for the life of application till the application is running. You can assay their value by constructor when we call constructor with "new" keyword.

delegation/forwarding

n object-oriented programming, delegation refers to evaluating a member (property or method) of one object (the receiver) in the context of another, original object (the sender). Delegation can be done explicitly, by passing the sending object to the receiving object, which can be done in any object-oriented language; or implicitly, by the member lookup rules of the language, which requires language support for the feature. Implicit delegation is the fundamental method for behavior reuse in prototype-based programming, corresponding to inheritance in class-based programming. The best-known languages that support delegation at the language level are Self, which incorporates the notion of delegation through its notion of mutable parent slots that are used upon method lookup on self calls, and JavaScript; see JavaScript delegation. The term delegation is also used loosely for various other relationships between objects; see delegation (programming) for more. Frequently confused concepts are simply using another object, more precisely referred to as consultation or aggregation; and evaluating a member on one object by evaluating the corresponding member on another object, notably in the context of the receiving object, which is more precisely referred to as forwarding (when a wrapper object doesn't pass itself to the wrapped object[1]). The delegation pattern is a software design pattern for implementing delegation, though this term is also used loosely for consultation or forwarding. In object-oriented programming, forwarding means that using a member of an object (either a property or a method) results in actually using the corresponding member of a different object: the use is forwarded to another object. Forwarding is used in a number of design patterns, where some members are forwarded to another object, while others are handled by the directly used object. The forwarding object is frequently called a wrapper object, and explicit forwarding members are called wrapper functions. Forwarding is often confused with delegation; formally, they are complementary concepts. In both cases, there are two objects, and the first (sending, wrapper) object uses the second (receiving, wrappee) object, for example to call a method. They differ in what self refers to on the receiving object (formally, in the evaluation environment of the method on the receiving object): in delegation it refers to the sending object, while in forwarding it refers to the receiving object. The difference between forwarding and delegation is the binding of the self parameter in the wrappee when called through the wrapper. With delegation, the self parameter is bound to the wrapper, with forwarding it is bound to the wrappee. ... Forwarding is a form of automatic message resending; delegation is a form of inheritance with binding of the parent (superclass) at run time, rather than at compile/link time as with 'normal' inheritance.

Can Multiple Catch Blocks executed in c#?

we can use multiple Catches block with every try but when any Exceptions is throw by debugger so every catches match this exception type with their signature and catch the exception by any single catch block so that means we can use multiple catches blocks but only one can executed at once

What is the difference between Interface and Abstract Class?

•A class can implement any number of interfaces but a subclass can at most use only one abstract class. •An abstract class can have non-abstract methods (concrete methods) while in case of interface all the methods has to be abstract. •An abstract class can declare or use any variables while an interface is not allowed to do so. •In an abstract class all data member or functions are private by default while in interface all are public, we can't change them manually. •In an abstract class we need to use abstract keyword to declare abstract methods while in an interface we don't need to use that. •An abstract class can't be used for multiple inheritance while interface can be used as multiple inheritance. •An abstract class use constructor while in an interface we don't have any type of constructor.

Dispose

•Dispose is also used to free unmanaged resources those are not in use like files, database connections in Application domain at any time. •Dispose explicitly it is called by manual user code. •If we need to dispose method so must implement that class by IDisposable interface. •It belongs to IDisposable interface. •Implement this when you are writing a custom class that will be used by other users.

Finalize

•Finalize used to free unmanaged resources those are not in use like files, database connections in application domain and more, held by an object before that object is destroyed. •In the Internal process it is called by Garbage Collector and can't called manual by user code or any service. •Finalize belongs to System.Object class. •Implement it when you have unmanaged resources in your code, and make sure that these resources are freed when the Garbage collection happens.

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.

Array Properties

•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.

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.


संबंधित स्टडी सेट्स

McKinney Maternal Test Bank for nclex

View Set

Lesson 5: Implementing a Public Key Infrastructure

View Set

Med Surg Chapter 23: Nursing Management: Patients With Gastric and Duodenal Disorders: PREPU

View Set

Measurement in Kinesiology (KIN 250) Exam #2

View Set

HESI Case Study: Benign Prostatic Hyperplasia

View Set