Exam Flashcards

1
Q

What is Managed or Unmanaged Code in C#?

A
  • Managed code is .NET code (VB.NET, C# etc.) that you write and compile to .NET CIL.
  • Unmanaged code is code that is not under .NET that compiles to direct machine code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Boxing and Unboxing in C#?

A
  • Boxing is the process of converting a value type to the type object or to any interface type implemented by this value type. When the CLR boxes a value type, it wraps the value inside a System.Object and stores it on the managed heap.
  • Unboxing extracts the value type from the object. Boxing is implicit; unboxing is explicit.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A
  • Structs are value types and classes are reference types.
  • Structs share most of the same syntax as classes, but are more limited than classes.
  • Unlike classes, structs can be instantiated without using a new operator.
  • Structs do not support inheritance and cannot contain virtual methods.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

A break will exit the loop completely, continue will just skip the current iteration.

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

What is the difference between constant and read only in C#?

A

Constants:
can be assigned values only at the time of declaration
Constant variables must be accessed using “Classname.VariableName”
Constants are known at compile time

Read Only:
Read only variables can be assigned values either at runtime or at the time of instance initialization via constructor
Read only variables must be accessed using the “InstanceName.VariableName”
Read only variables are known at run time.

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

What is the difference between ref and out keywords in C#?

A
  • ref tells the compiler that the object is initialized before entering the function
  • out tells the compiler that the object will be initialized inside the function.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define Property in C#.net?

A
A property is a member that provides a flexible mechanism to read, write, or compute the value of a private field. Properties can be used as if they are public data members, but they actually include special methods called accessors.
class Person
{
 private string name; //field
 public string Name //property
 {
   get { return name; }
   set { name = value; }
 }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the difference between string and StringBuilder?

A

String:
String is immutable. Immutable means once we create string object we cannot modify. Any operation like insert, replace or append happened to change string simply it will discard the old value and it will create new instance in memory to hold the new value.
StringBuilder:
String builder is mutable it means once we create string builder object we can perform any operation like insert, replace or append without creating new instance for every time.

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

What is delegates in C#.

A
  • A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.
  • Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegateclass.
  • List can contain 0, 1, or many method references
  • Once a delegate is assigned a method, it behaves exactly like that method
    That is, you can perform method calls, via the delegate
    In the context of pub/sub systems, a delegate holds the list of subscribers
    That is, the list of methods to call when an event occurs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Three pillars of Object-Oriented Programing (OOP) are Encapsulation, Inheritance, Polymorphism. Explain each of them and why they are important?

A
  • Encapsulation refers to the hiding of data and implementation details.
  • when encapsulating data and details into classes and objects programs become easier to manage and understand. (e.g methods encapsulated in classes)
  • Encapsulation is implemented by using access modifiers. An access modifier defines the scope and visibility of a class member.
  • Inheritance allows us to define a class based on another class. This makes creating and maintaining an application easy.
  • The class whose properties are inherited by another class is called the Base class. The class which inherits the properties is called the Derived class
  • polymorphism occurs when there is a hierarchy of classes and they are related through inheritance from a common base class.
  • Polymorphism means that a call to a member method will cause a different implementation to be executed depending on the type of object that invokes the method.
  • Simply, polymorphism means that a single method can have a number of different implementations.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain uses of delegates in C#?

A

Delegates are especially used for implementing events and the call-back methods

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

What is sealed class in c#?

A

The sealed keyword provides a level of protection to your class so that other classes cannot inherit from it.

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

Describe the differences between the public, private and protected access modifiers. Give an example of use for each type

A
The public access modifier makes the type or member accessible by any other code in the same assembly or any other assembly that references it.
The private access modifier makes the type or member accessible only by code in the same class or struct. 
The protected access modifier is very similar to private with one difference; it can be accessed in the derived classes. So, a protected member is accessible only from derived classes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are partial classes?

A
  • Partial class splits the definition of a class over two or more source files.
  • You can create a class definition in multiple files, but it will be compiled as one class.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Explain how to create a read-only property for a class and provide example of use.

A
The readonly modifier prevents a member of a class from being modified after construction. It means that the field declared as readonly can be modified only when you declare it or from within a constructor.
class Person {
 private readonly string name = "John";
 public Person(string name) {
   this.name = name;
 }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is IEnumerable<> in c#?

A

It’s an interface implemented by Collection types in .NET that provide the Iterator pattern. There is also the generic version which is IEnumerable.

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

C# does not support multiple-inheritance? Explain why and what are the alternatives to multiple-inheritance?

A

NET and Java designers did not allow multiple inheritance because they reasoned that adding MI added too much complexity to the languages while providing too little benefit.
You can use interfaces instead.

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

What is the difference between checked and unchecked exceptions in c#

A

The checked keyword throws an overflowexception when a calculation causes an arithmatic overflow to occur
The unchecked keyword prevents the runtime from throwing an OverFlowException during execution and is the default.

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

What is the Constructor Chaining in C#?

A

Using a constructor to invoke another constructor, either within itself or in the base class

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

What’s the difference between the Array.CopyTo() and Array.Clone() in C#?

A

The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array

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

Can Multiple Catch Blocks execute in c#?

A

No, because only one of the exceptions will be thrown. Execution leaves the try block as soon as the exception is thrown, and assuming there’s a matching catch block, it continues there. It doesn’t go back into the try block, so you can’t end up with a second exception.

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

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

A
The singleton pattern is a software design pattern that is used to restrict instantiation of a class to one object. This is useful when we require exactly one object of a class to perform our operations. In this pattern we ensure that the class has only one instance and we provide a global point of access to this object. The normal implementation of singleton design pattern in C#like this.
public class Singleton
{
    private static Singleton _instance;
    private Singleton()
    {
        Console.WriteLine("Instance created");
    }
public void Log(string message)
{
    Console.WriteLine(message);
}
    public static Singleton Instance
    {
        get
        {
            if (null == _instance)
            {
                _instance = new Singleton();
            }
        return _instance;
    }
} }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is multicast delegate in c#?

A

Delegate objects can be composed using the “+” operator. A composed delegate calls the two delegates it was composed from. Only delegates of the same type can be composed. The “-“ operator can be used to remove a component delegate from a composed delegate.
Using this property of delegates you can create an invocation list of methods that will be called when a delegate is invoked. This is called multicasting of a delegate.

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

What is difference between Equality Operator (==) and Equals() Method in C#.

A

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

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

How to use Nullable<> Types in .Net?

A

Nullable types are values which you can assign normal range of values as well as null values.
For example, you can store any value from -2,147,483,648 to 2,147,483,647 or null in a Nullable variable. Similarly, you can assign true, false, or null in a Nullable variable. Syntax for declaring a nullable type is as follows −
< data_type> ? = null;

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

What are different ways that a Method can be overloaded.

A
  • Different Parameter datatypes
  • Different number of parameters
  • Different order of parameters
  • All of the above
27
Q

What are generics in c#.net?

A
Generics refers to the technique of writing the code for a class without specifying the data type(s) that the class works on.
You specify the data type when you declare an instance of a generic class. This allows a generic class to be specialized for many different data types while only having to write the class once.
A great example are the many collection classes in .NET. Each collection class has it's own implementation of how the collection is created and managed. But they use generics to allow their class to work with collections of any type.
28
Q

Describe the accessibility modifiers in c#.Net.

A
private
The type or member can be accessed only by code in the same class or struct.
protected
The type or member can be accessed only by code in the same class, or in a class that is derived from that class.
internal
The type or member can be accessed by any code in the same assembly, but not from another assembly.+
protected internal The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly.1
private protected The type or member can be accessed only within its declaring assembly, by code in the same class or in a type that is derived from that class
29
Q

What is Virtual Method in C#?

A

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 overriden in the derived class. We create a virtual method in the base class using the virtual keyword and that method is overriden in the derived class using the override keyword

30
Q

What are the Difference between Array and ArrayList in C#.Net?

A

Arrays are strongly typed, and work well as parameters. If you know the length of your collection and it is fixed, you should use an array.
ArrayLists are not strongly typed, every Insertion or Retrial will need a cast to get back to your original type. If you need a method to take a list of a specific type, ArrayLists fall short because you could pass in an ArrayList containing any type. ArrayLists use a dynamically expanding array internally, so there is also a hit to expand the size of the internal array when it hits its capacity.
What you really want to use is a generic list like List. This has all the advantages of Array and ArrayLists. It is strongly typed and it supports a variable length of items.

31
Q

What is Object Serialization and deserialization in C# ?

A

Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.

32
Q

What is the use of Using statement in C#?

A

The reason for the “using” statement is to ensure that the object is disposed as soon as it goes out of scope, and it doesn’t require explicit code to ensure that this happens.
As per http://www.codeproject.com/KB/cs/tinguusingstatement.aspx, the .NET CLR converts
using (MyResource myRes = new MyResource()) { myRes.DoSomething(); }
to
{ // limits scope of myRes MyResource myRes= new MyResource(); try { myRes.DoSomething(); } finally { // Check for a null resource. if (myRes!= null) // Call the object’s Dispose method. ((IDisposable)myRes).Dispose(); }

33
Q

What is jagged array in C#.Net?

A

A jagged array is an array whose elements are arrays. So it is basically an array of arrays
int[ ][ ] is an array of int[ ], each of which can be of different lengths and occupy their own block in memory.

34
Q

Explain Anonymous type in C#?

A

Anonymous type, as the name suggests, is a type that doesn’t have any name. C# allows you to create an object with the new keyword without defining its class. The implicitly typed variable- varis used to hold the reference of anonymous types.
They are declared with the creation of the delegate instance with the delegate keyword.

static void Main(string[] args)
{
    var myAnonymousType = new { firstProperty = "First", 
                                secondProperty = 2, 
                                thirdProperty = true 
                              };
}
35
Q

Compare and contrast interfaces and delegates.

A
An interface is a completely abstract class that contains only abstract members. They contain properties, methods etc but cannot contain fields(variables). When a class implements an interface it must define or implement all of its methods. The interface is the what and the class is the how.  delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegateclass. A delegate can be used to call multiple methods at runtime.
Once a delegate type is declared, a delegate object must be created with the new keyword and be associated with a particular method. When creating a delegate, the argument passed to the new expression is written similar to a method call, but without the arguments to the method.delegates are used to reference any methods that has the same signature as that of the delegate. In other words, you can call a method that can be referenced by a delegate using that delegate object.
Delegates vs Interfaces
- Delegates are similar to interfaces:
- they specify a contract between a caller and an
implementer.
- Interface: specifying an entire interface
- Delegate: specifying a single function
- Interface: created at compile-time
-Delegate: created at run-time
36
Q

What is LINQ in C#?

A

In a nutshell, LINQ (Language-Integrated Query) allows you to write queries directly in your code. Those queries can be on relational databases, but also on XML or in-memory container objects, such as arrays and lists. More information is available in MSDN library: http://msdn.microsoft.com/en-us/library/bb308959.aspx

37
Q

What is File Handling in C#.Net?

A

Data stored in a file lasts longer than that on memory. A file is persistent. In C# we handle files with System.IO.
Streamreader
Streamwriter
etc

38
Q

What is Reflection in C#.Net?

A

Reflection objects are used for obtaining type information at runtime. The classes that give access to the metadata of a running program are in the System.Reflection namespace.
The System.Reflection namespace contains classes that allow you to obtain information about the application and to dynamically add types, values, and objects to the application.
It allows view attribute information at runtime.
It allows examining various types in an assembly and instantiate these types.
It allows late binding to methods and properties
It allows creating new types at runtime and then performs some tasks using those types

39
Q

Is string a value type or reference type in C#, explain your answer?

A

It’s a reference type.
It can’t be a value-type, as value-types need a known size for the stack etc. As a reference-type, the size of the reference is known in advance, even if the size of the string isn’t.
It behaves like you expect a value-type to behave because it is immutable; i.e. it doesn’t* change once created. But there are lots of other immutable reference-types. Delegate instances, for example.
*=except for inside StringBuilder, but you never see it while it is doing this.

40
Q

What is the difference between Error and Exception in C#?

A

An exception is a class that takes advantage of language semantics. Exceptions interrupt execution up the stack until caught. An exception can be used to convey an error, but more generally is used to convey that something exceptional has occurred.
Errors, on the other hand, can be exceptional or not.
There are several kinds of errors:
User error - this should be handled without an exception
Syntax error - this shouldn’t compile in statically typed languages (in dynamic languages, they’re a little harder to discover)
Runtime error - this will either result in an exception, or silently fail (usually creating unexpected results)
Really, exceptions should be limited to handling runtime errors, since a user inputting bad data is not “exceptional.” To handle user errors, you should take the following approaches:
Prevent bad data from being input (front-end validation)
Prevent bad data from being persisted (back-end validation)
Exceptions should be used as a “last line of defense” for user error. If you’re writing a persistence layer, you can rely on exceptions to ensure that bad data that falls through validation does not get persisted. You should, however, fix any of these by putting a fix in the validation that prevents the error from occurring in the first place.

41
Q

What is the difference between Int and Int32 ?

A

Both the same!
Int16: 2 bytes
Int32 and int: 4 bytes
Int64 : 8 bytes

42
Q

What is Null Coalescing Operator in C#?

A

The ?? returns the left-hand operand if the operand is not null; otherwise it returns the right hand operand

43
Q

What is the difference between Stack and Heap memory

A

The Stack is basically responsible for keeping track of what’s executing in our code (or what’s been “called”). The Heap is more or less responsible for keeping track of our objects (our data, well… most of it; we’ll get to that later).
The Stack is like a series of boxes stacked one on top of the next. We keep track of what’s going on in our application by stacking another box on top every time we call a method (called a Frame). We can only use what’s in the top box on the Stack. When we’re done with the top box (the method is done executing) we throw it away and then use the stuff in the previous box on the top of the Stack. The Heap is similar except that its purpose is to hold information (not keep track of execution most of the time) so anything in our Heap can be accessed at any time. With the Heap, there are no constraints as to what can be accessed like in the Stack. The Heap is like the heap of clean laundry on our bed that we have not taken the time to put away yet; we can grab what we need quickly. The Stack is like the Stack of shoe boxes in the closet where we have to take off the top one to get to the one underneath it.

44
Q

What are the differences between Dispose() and Finalize()?

A
Finalize gets called by the GC when this object is no longer in use.
Dispose is just a normal method which the user of this class can call to release any resources.
If user forgot to call Dispose and if the class have Finalize implemented, then GC will make sure it gets called.
45
Q

How to return multiple values from a function in C#?

A

Either:
Pass in your return values by pointer, and modify them inside the function. You declare your function as void, but it’s returning via the values passed in as pointers.
Or:
Define a struct that aggregates your return values.

46
Q

Why do we need delegates in C#?

A

Delegates allow methods to be passed as parameters
can be used to define callback methods
can be chained together eg multiple methods can be called from a single events

47
Q

What is Encapsulation and Data hiding in C#?

A
Encapsulation (information hiding)means combining members together within a class; it also means restricting access to the inner workings of that class. Encapsulation is implemented by using access modifiers.
Data hiding is restricting outside access of class members using access modifiers like protected, private and internal
48
Q

How to iterate over a Dictionary in C#?

A

foreach(KeyValuePair entry in myDic) { // do something with entry.Value or entry.Key }

49
Q

What are differences between Dictionary class and Hashtable class?

A

Hashtable and Dictionary are collection of data structures to hold data as key-value pairs. Dictionary is generic type, hash table is not a generic type. The Hashtable is a weakly typed data structure, so you can add keys and values of any Object Type to the Hashtable. The Dictionary class is a strongly types < T Key, T Value > and you must specify the data types for both the key and value

50
Q

When to use struct instead of class in C#?

A

AVOID defining a struct unless the type has all of the following characteristics:
It logically represents a single value, similar to primitive types (int, double, etc.).
It has an instance size under 16 bytes.
It is immutable.
It will not have to be boxed frequently.
In all other cases, you should define your types as classes.

51
Q

What is the difference between string and String in C# ?

A

string is an alias in C# for System.String. So technically, there is no difference. It’s like int vs. System.Int32.
As far as guidelines, I think it’s generally recommended to use string any time you’re referring to an object

52
Q

What is the difference between a process and a thread?

A

Process
Each process provides the resources needed to execute a program. A process has a virtual address space, executable code, open handles to system objects, a security context, a unique process identifier, environment variables, a priority class, minimum and maximum working set sizes, and at least one thread of execution. Each process is started with a single thread, often called the primary thread, but can create additional threads from any of its threads.
Thread
A thread is an entity within a process that can be scheduled for execution. All threads of a process share its virtual address space and system resources. In addition, each thread maintains exception handlers, a scheduling priority, thread local storage, a unique thread identifier, and a set of structures the system will use to save the thread context until it is scheduled. The thread context includes the thread’s set of machine registers, the kernel stack, a thread environment block, and a user stack in the address space of the thread’s process. Threads can also have their own security context, which can be used for impersonating clients

53
Q

What is Enumeration in C#?

A

Enumeration is a user-defined integer type. helps to specify a set of acceptable
values that instances of that enumeration can contain. can also give the values
user-friendly names.

Benefits of using instead of plain integers:

Code easier to maintain by helping to ensure that variables are assigned
only legitimate, anticipated values.

Allowing you to refer to integer values by descriptive names rather than by
obscure “magic” numbers.

Basically, Enums define variables that represent members of a fixed set.
Some sample Enum uses include month names, days of the week, cards in a deck, etc.

The enum keyword is used to declare an enumeration: a type that consists of a set of named constants called the enumerator list.
By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1.
For example, in the following enumeration, Sun is 0, Mon is 1, Tue is 2, and so on:
enum Days {Sun, Mon, Tue, Wed, Thu, Fri, Sat};
You can also assign your own enumerator values:
enum Days {Sun, Mon, Tue=4, Wed, Thu, Fri, Sat};

54
Q

Explain Static Class Members.

A

Class members (variables, properties, methods) can also be declared as static. This makes those members belong to the class itself, instead of belonging to individual objects. No matter how many objects of the class are created, there is only one copy of the static member

55
Q

How to add a ReadOnly property in C#.NET?

A

Properties can be made read-only by having only a get accessor in the implementation

56
Q

How to prevent a class from being inherited in C#.NET?

A

Making it a sealed class prevents it being inherited by other classes

57
Q

Explain use of Abstract and Sealed Classes in C#?

A

The sealed modifier prevents a class from being inherited and the abstract modifier requires a class to be inherited.

58
Q

What is Garbage Collection .Net?

A

Garbage collection, in the context of .NET, is the process by which the common language runtime (CLR) of .NET framework manages the memory by allocating and releasing memory automatically
The advantages that GC provides include:
the elimination of memory de-allocation code in applications
optimized memory usage in managed heap
clearing up of memory of reclaimed objects that are no longer in use (which helps to initialize managed objects allocated in future and provision of memory safety of objects to avoid an object using content of another.

59
Q

What is the difference between a value type and a reference type? Provide example of practical use for each one?

A

The built-in data types, such as int and double, are used to declare variables that are value types. Their value is stored in memory in a location called the stack.
For example, the declaration and assignment statement int x = 10; can be thought of as:

Reference types are used for storing objects. For example, when you create an object of a class, it is stored as a reference type.
Reference types are stored in a part of the memory called the heap.
When you instantiate an object, the data for that object is stored on the heap, while its heap memory address is stored on the stack.
That is why it is called a reference type - it contains a reference (the memory address) to the actual object on the heap.

60
Q

Explain Generic Types in .Net. What are some practical uses of Generic in .Net?

A

Generics allow the reuse of code across different types.

For example, a method that swaps the values of its two parameters

61
Q

What is a static class? Explain the purpose and uses of a static class in C#.

A
A static class can contain only static members. 
You cannot instantiate an object of a static class, as only one instance of the static class can exist in a program.
Static classes are useful for combining logical properties and methods. A good example of this is the Math class.
It contains various useful properties and methods for mathematical operations. 
For example, the Pow method raises a number to a power:
62
Q

Explain the purpose of using delegates in programming

A

A delegate is a class that can hold a reference to a method. Unlike other classes, a delegate class has a signature, and it can hold references only to methods that match its signature. A delegate is thus equivalent to a type-safe function pointer or a callback. While delegates have other uses, the discussion here focuses on the event handling functionality of delegates. A delegate declaration is sufficient to define a delegate class. The declaration supplies the signature of the delegate, and the common language runtime provides the implementation

63
Q

What is unsafe code in .Net? What is the advantage of using unsafe VS safe code?

A

Unsafe is a C# programming language keyword to denote a section of code that is not managed by the Common Language Runtime (CLR) of the .NET Framework, or unmanaged code. Unsafe is used in the declaration of a type or member or to specify a block code. When used to specify a method, the context of the entire method is unsafe.
advantages of UnSafe Mode
It increase the performance of the Program.
We use fixed buffers inside an unsafe context. With a fixed buffer, you can write and read raw memory without any of the managed overhead.
It provides a way to interface with memory.
Disadvantages of Unsafe Mode
- It increase the responsibility of the programmer to check for security issues and extra developer care is paramount to averting potential errors or security risks.
- It bypasses security. Because the CLR maintains type safety and security, C# does not support pointer arithmetic in managed code, unlike C/C++. The unsafe keyword allows pointer usage in unmanaged code. -
- However, safety is not guaranteed because strict object access rules are not followed.
It also avoids type checking, that can generate errors sometimes.

64
Q

able below provides names of design patterns in three different categories.
Explain at least two from each category (total of six design patterns) and circumstances
when it is appropriate to use each one.

A

Creational Patterns
Factory Method
Factory pattern deals with the instantiation of object without exposing the instantiation logic. In other words, a Factory is actually a creator of object which has common interface.
Singleton
Singleton pattern creates a class which can have a single object throughout the application, so that whenever any other object tries to access the object of the class, it will access the same object always

Structual
Adapter
Adapter pattern converts one instance of a class into another interface which client expects. In other words, Adapter pattern actually makes two classes compatible.
Flyweight
Flyweight allows you to share bulky data which are common to each object. In other words, if you think that same data is repeating for every object, you can use this pattern to point to the single object and hence can easily save space.
Mediator pattern ensures that the components are loosely coupled, such that they don’t call each others explicitly, rather they always use a separate Mediator implementation to do those jobs.
Observer
When there are relationships between one or more objects, an observer will notify all the dependent elements when something is modified in the parent. Microsoft already implemented this pattern as ObservableCollection. Here let me implement the most basic Observer Pattern