You are on page 1of 22

OOPs Difference FAQs-1 1. What are the differences between TypeOf() and GetType()? S.

No 1 2 TypeOf() Its an operator Can't be overloaded GetType() Its a method Has lot of overloads

2. What are the differences between const and readonly? S.No 1 2 3 4 const It cannot be static It is evaluated at design time It is initialized at declaration It must be of integral type or enumeration readonly It can be instance level or static It is evaluated at run time It is initialized at declaration or in constructor In addition, it can have complex types with new keyword and enumerations are not allowed

3. What are the Differences between Abstract Class and Interface? S.No 1 Abstract Class Default Implementation: In Abstract Class we can provide default implementation. Inheritance/Implementation: A class can inherit only one abstract class When to use ? We go for Abstract classes on such situations where we need to give common functionality for group of related classes Default Implementation Pros/Cons: If we add a new method, then we can provide a default implementation and so no need to make any change to existing work Constants type support: Static and Instance constants are possible Interface Default Implementation: Interface has only signature, we cannot provide implementation in interface. Inheritance/Implementation: A Class can implement any number of Interfaces When to use ? We go for Interface on such situations where we need to give common functionality for group of un-related classes Default Implementation Pros/Cons: If we add a new method, then we need to change all the existing work

Constants type support: Only Static constants are possible

Support for Automatic Properties: Abstract class can have automatic properties. Access Modifiers (public, private, protected, internal, protected internal): Abstract Class can have access modifiers for subs, functions, properties

Support for Automatic Properties: Interface cannot have automatic properties. We need to implement all the properties defined in interface into all its implementors. Access Modifiers (public, private, protected, internal, protected internal): Interface does not have access modifiers for subs, functions, properties. Everything defined inside the interface is assumed public modifier Purpose: Interface suits to implement peripheral requirements. i.e. both person and vehicle class can implement IRun interface.

Purpose: Abstract Class suits to implement core requirements that is shared among common type of objects. i.e. Person abstract class can be inherited by Manager, Supervisor, Clerk, Administrator Support for Data Fields: Abstract class can have data fields.

Support for Data Fields: Interface cannot contain data fields. However in .NET we can have abstract properties in interface. However just like methods we need to implement those abstract properties inside the implementor class. Performance: Interfaces require more time to find the actual method in the corresponding classes. Hence it is slower than abstract class. Class It is reference type It is stored on heap It supports inheritance It is suitable for complex data structures where inheritance, overriding is required or we need to create objects example: DataSet,ArrayList can handle large data.

10

Performance: An abstract class is fast

4. What are the differences between Structure and Class? S.No 1 2 3 4 Structure It is value type It is stored on stack It does not support inheritance It is suitable for small data structure usually where inheritance, overriding is not required example: int a=100;

5 6 7

'this' pointer it will not work in structure. Structure cannot be declared as private or protected. Structure contains only data member

'this' pointer will work only in class. Class can be declared public as well as private. Class contains both data member and member function

8 9 10 11 12 13 14 15 16 17

Default access specifier for structure is public Structure does not require constructor Structures are not destroyed using GC. Faster in access. Supports only interface inheritance. They do not have destructors They do no have explicit parameterless constructors We cannot put sealed /abstract modifiers before the structures. Easier memory management examples: int, short,long,DateTime, Point (predefined)

Default access specifier for class is private Class requires constructor Objects created from classes are terminated using Garbage collector. Not faster in access than structure. Supports both implemenation and interface inheritance. Classes have destructors They can have explicit parameterless constructors Sealed/abstract modifers can be put before classes. Comparitively Difficult memory management examples: SqlConnection,DataView(predefined classes)

5. What are the differences between property and indexer? S.No 1 2 3 4 Property Identified by its name. Accessed through a simple name or a member access. Can be a static or an instance member. A get accessor of a property has no parameters. Indexer Identified by its signature. Accessed through an element access. Must be an instance member. A get accessor of an indexer has the same formal parameter list as the indexer.

A set accessor of a property contains the implicit value parameter.

A set accessor of an indexer has the same formal parameter list as the indexer, in addition to the value parameter. Overriding We need to provide different implementation than base class Has same signature Otherwise called Run-time Polymorphism

6. What are the differences between overloading and overriding? S.No 1 Overloading Same name in same / derived class but with different / type of parameter Has different signature Otherwise called Compile-time Polymorphism

2 3

7. What are the differences between Value Types and Reference Types? S.No 1 2 Value Types It is stored on stack It can be accessed directly Reference Types It is stored on heap It can be accessed through references.Reference type variable will hold object reference. Lifetime of reference type is managed by .net framework Examples: All arrays, String, Class types, Delegate Reference type variables can hold null values.

Life time of value type is determined by lifetime of variable that contain them Examples: All numeric data type, Boolean, char, Date, Structure, enumerations Value types do not accept null value. Value types can be made to accept null values by using null coalescence operator. Value types cannot be inherited. Value types other than structure cannot implement interfaces. Boxing is performed to convert value type to an object and unboxing is performed to convert an object into a value type. Value type is inherited from System.ValueType namespace which is inherited from System.Object.

6 7 8

Reference types can be inherited. Class and Interface of Reference types can implement interfaces. You can directly assign a reference type to an object and an object to a reference type without boxing and unboxing. Reference type is inherited from System.Object directly.

10

When one value type variable is assigned to another, both value type variables will contain same data but independent copy. Changing value of one value type variable will not impact value of the other value type variable. CLR (Common Language Runtime) does not perform memory management of value types. Value types are primitive data types.

When one reference type variable is assigned to another, both reference type variables will be referencing to the same object. If one reference type changes value of the object then the other reference type variable will also point to the modified object. Memory management of reference types is automatically done by CLR.

11

12

Reference types are not primitive in nature. Reference types deal with objects.

Note: Object is not any kind of type. You can create object of structure as well as Class Are not type: Namespaces, Modules, Events, properties, procedures, variables, constants, & fields. Reference: http://onlydifferencefaqs.blogspot.in/2012/07/oops-difference-faqs-1.html OOPs Difference FAQs-2 Difference between Events and Delegates S.No 1 2 3 Events Event can be used in an interface definition Event can only be invoked from the class that declares it Event comes with its pair of accessors i.e Add and Remove. An event is always assigned and unassigned with a += and -= operator. Delegates Delegate cannot be used in an interface definition Delegates can be invoked from child classes and clients. There is no pair of accessors concept in delegates.

Event has a restrictive signature Delegates do not have restrictive and must always be of the form signature as like events Event (object source, EventArgs args)

Difference between Class and Object

S.No 1 2 3

Class It is a datatype that contains the programming logic. Class is visible in the source code and resides in hard disk. Class is like a template or blueprint of the object. It implements reusability,encapsulation, inheritance Example:Button is a class with properties like Text,BackColor, events like click, methods like Focus We can create subclasses

Object It is a chunk of memory that implements the class logic. Object is in the RAM and not visible in source code. It is the real world implementation of the class. Each object has its own copy of data. Example: Button1, Button2 are the objects of Button class.

We cannot create sub-objects

Difference between Private and Static Constructor S.No Static constructor Private constructor 1 A static constructor is called before the first instance is created. i.e. global initializer. Static constructor will be called first time when the class is referenced.Static constructor is used to initialize static members of the class. Private constructor is called after the instance of the class is created. Static members will not be initialized either by private or public constructor.

The static constructor will only be The private constructor will be executed once. executed each time it is called.

Difference between properties and methods S.No 1 2 Properties Properties are used to represent data Properties are created by using getter and setter i.e., get{} and set{} Methods Methods are used to performs actions Methods create like public void method1(parameter list here)

Difference between Singleton Pattern and static class S.No Singleton Pattern Singleton pattern maintains single instance. 2 A singleton can extend classes and implement interfaces. static class We cannot create instance for static class. A static class cannot . Note: It can extend classes, but it does not inherit their instance members. A static class is generally initialized when it is first loaded, leading to potential class loader issues. static class cannot be handled polymorphically.

A singleton can be initialized lazily or asynchronously. Singletons can be handled polymorphically without forcing their users to assume that there is only one instance.

Singleton Class can have value Static are always just shared and when Class object instantiated have no instance but multiple between server and client, such a references. way if three client want to have a shared data between them Singleton can be used.Thats why singleton class can be used for state mangement in stateless scenarios like shopping cart scenario. We can pass singleton object as parameter Singleton provides flexibility and also provides sort of a mechanism to control object creation based on various requirements. They can be extended as well if need arises. In other words we are not always tied to a particular implementation. With Singleton we have the flexibility to make changes as when situation demands. We cannot pass parameter in static class Static classes once defined could not accomodate any future design changes as by design static classes are rigid and cannot be extended.

6 7

Reference: http://onlydifferencefaqs.blogspot.in/2012/07/oops-difference-faqs-2_11.html

OOPs Difference FAQs-3 1.Difference between Abstraction and Encapsulation S.No 1 2 Abstraction Encapsulation

Abstraction solves the problem Encapsulation solves the problem in the design level. in the implementation level. Abstraction is used for hiding Encapsulation means hiding the the unwanted data and giving code and data into a single unit to relevant data. protect the data from outside world. Abstraction allows us to focus Encapsulation means hiding the on what the object does internal details or mechanism of instead of how it does it how an object does something. Abstraction- Outer layout, used in terms of design. For Example:Outer Look of a Mobile Phone, like it has a display screen and keypad buttons to dial a number. Encapsulation- Inner layout, used in terms of implementation. For Example:Inner Implementation detail of a Mobile Phone, how keypad button and Display Screen are connected with each other using circuits

2.Difference between Composition and Aggregation S.No 1 Composition Defines a strongly-coupled relationship between two entities, where the one entity is part of another, and both need each other for their existence. Aggregation Defines a weakly-coupled relationship between two entities, where one entity could be part of another, but either can exist without the other, independantly.

2 3 4 5

e.g. Human body and the e.g.School and teacher. Heart. Composition implies real Aggregation does not necessarily ownership of its components own any of its aggregates. Composition has a stronger Aggregation has weaker or looser bond of its components. bonds with its aggregates. Composition has components Aggregation has aggregates that that exist at the inner level. live at the outer level.

3.Difference between Private Class and Sealed Class S.No 1 Private Class Sealed Class

A Private class can only be A Sealed class can be accessed by

accessed by the class it is defined any class.Private Constructor of a and contain within - it is Private Class = Sealed Class. completely inaccessible to outside classes. 2 In private Class,we can create a In Sealed class we can not create a constructor and therefore we can constructor of that class, so no create an instance of that class. instance of that class is possible. The main use of Private class is The sealed classes are mainly used to to create a user-defined type, prevent inheritance features of object which we want to be accessible to oriented programming. that class only.

Note: Private class(i.e private constructor) is also used to implement singleton classes(pattern). Singleton means "A single-instance object, and it simplify complex code. Singletons have a static property that we must access to get the object reference." Example for Private Class: public class A { private class B { } B b = new B(); } public class C { A.B b = new A.B(); // ERROR } Example for Sealed Class: public sealed class A { } public class B : A //ERROR { } 4.Difference between Static Class and Sealed Class S.No 1 2 3 Static Class Sealed Class

We can neither create their We can create their instances, but instances, nor inherit them cannot inherit them They can have static members They can contain static as well as only. nonstatic members. Static classes are used when a The sealed classes are mainly

class provides functionality that used to prevent inheritance is not specific to any unique features of object oriented instance. programming. Example for Static Class: static class Program { } Example for Sealed Class: sealed class demo { } class abc:demo { --Wrong } 5.Difference between Virtual method and Abstract method S.No 1 Virtual method Abstract method be the

Overriding : Overriding : Virtual method may or may not An abstract method should override by inherited class. overriden by inherited class. i.e.,Virtual method provide the i.e.,Abstract method forces derived class with the option of derived class to override it. overriding it. Virtual = = Overridable abstract == MustOverride

Implementation: Virtual method implementation.

has

Implementation: an Abstract method does not provide an implementation. Necessity to Implement: Abstract methods in a class contain no method body, and are implicitly virtual

Necessity to Implement: Virtual methods allow subclasses to provide their own implementation of that method using the override keyword Scope : Virtual methods members only. Instancing : scope

Scope : to Abstract method's scope to members and classes Instancing :

Virtual methods - Not applicable, as we can't create instance for members, it is possible only with classes.

Abstract method - directly NO, but other way,Yes.We can create an instance of a class that derives from an abstract class. And we can declare a type Abstract class and instantiate that as a derived class.

Example: public abstract class Test { public abstract void A(); // Abstract method

public virtual void B() { Console.WriteLine("Test.B"); } // Virtual Method } public class InheritedTest : Test { public override void A() { Console.WriteLine("InheritedTest.A"); } //Method B implementation is optional public override void B() { Console.WriteLine("InheritedTest.B"); } } 6.Difference between Class and Static Class S.No 1 2 3 Class Class has Instance Members Static Class Static class does not have Instance Members

In Class, Constructor has Access In Static Class, Constructor does not Specifier. have Access Specifier. In Class Constructor, initiation is In Static Class ,Constructor will be done every time when an object called only one time is created for the class In Class, Class members can be In Static Class, members can be accessed through class object. accessed through its Class name only

7.Difference between Method Overloading and Method overriding in C# S.No 1 Method Overloading Method Overriding

Method Overloading is passing Method Overriding is redifining parent same message for different class function to the child class functionality Method Overloading is between Method Overriding is between the the same function name with the same method. different signature Method Overloading does not Method Overriding checks the return check for the return type. type. Method Overloading takes place Method Overriding takes place in the same class. between parent and child classes Method binding Overloading is static Method Overriding binding. is a dynamic

3 4 5

Reference: http://onlydifferencefaqs.blogspot.in/2012/08/oops-difference-faqs-3.html OOPs Difference FAQs-4 1.Difference between String and StringBuilder S.No 1 2 String StringBuilder

String class belongs to the StringBuilder class belongs to the namespace System. namespace System.Text. String class is immutable. Immutable means that the string cannot be changed. Consider the following example: class sampleClass { public static void Main() { string sampleStr = "Hai"; sampleStr = "Hello"; Console.WriteLine(sampleStr); } } Output of this code will be: Hello In this example, you have created a string called sampleStr. You have initially assigned the value "Hai". And StringBuilder class is mutable. Consider the following example: class sampleClass { public static void Main() { StringBuilder sampleSB = new StringBuilder("Hai",10); sampleSB = new StringBuilder("Hello"); Console.WriteLine(sampleSB); } } Output of this code will be: Hello In this example, you are doing the same thing. But the string "Hai" will be overwritten as "Hello" and no new strings will be created in the memory.

then you try to overwrite its value with "Hello". You get the overwritten value as output. But the problem lies in the number of strings that get created in memory. When you create the string as "Hai", this string gets created in the memory. When you try to change the value to "Hello", instead of overwriting the existing "Hai" string it will create a new string in the memory and assign this new string "Hello" to sampleStr. 3 You can directly assign a string to string class instance. For example, String sampleStr = "Hai" is valid. You cannot directly assign a string to StringBuilder instance. For example, StringBuilder sampleSB = "Hai" will lead to the following error: "cannot implicitly convert type 'string' to 'System.Text.StringBuilder' " You can assign a string to StringBuilder using the following statement: StringBuilder sampleSB = new StringBuilder("Hai"); String concatenation is done using Append method. Here is an example: class sampleClass { public static void Main() { StringBuilder sampleSB = new StringBuilder("Hello!"); sampleSB.Append("Good Day!"); Console.WriteLine(sampleSB); } } Output of this code will be: Hello! Good Day!

String concatenation is done using + operator. Here is an example: class sampleClass { public static void Main() { string sampleStr = "Hello!"; sampleStr += " Good Day!"; Console.WriteLine(sampleStr); } } Output of this code will be: Hello! Good Day! Here you have used += operator to perform both concatenation and assignment using single operator. You can also use + and = separately as shown below: sampleStr = sampleStr + " Good Day!";

During string concatenation, During string concatenation, additional memory will be additional memory will be allocated allocated. if and only if the string buffer's capacity is reached. During string concatenation, additional memory will be allocated if and only if the string buffer's capacity is reached. You cannot set a limit (specifying how many strings can be concatenated) to a string object using string class. If the number of concatenations to be done is random or not known, then it is recommended to use stringBuilder You can set a limit to StringBuilder using the member called capacity which will by default have the value 16. You can override it to any number. The maximum value acceptable is equivalent to MaxValue of Int32. If you feel that you do not want to reserve 16 as the capacity then you can very well redefine it. However the capacity will dynamically grow based on the number of strings that you append. Here is an example demonstrating the usage of capacity: class sampleClass { public static void Main() { StringBuilder sampleSB = new StringBuilder(); Console.WriteLine( sampleSB.Capacity); sampleSB.Capacity = 1; Console.WriteLine( sampleSB.Capacity); sampleSB.Append("str1"); sampleSB.Append("str2"); Console.WriteLine( sampleSB.Capacity); } } Output of this code will be: 16 1 8

2.Difference between Delegate and Interface S.No 1 Delegate Interface both

Delegates can only be Interface can include methods. Here is an example: properties and methods.

delegate sampleDelegate();

void Here is an example for an interface: interface ItestInterface { int paraml { get; set; } void sampleMethod(); }

Delegate can be applied to When a class implements an only one method at a time interface, it can implement all the methods associated with it You can use a delegate that is You can use an interface only visible in your scope when your class or struct implements it Within a class, you can implement the same delegate any number of times. Assume that either sampleClass1 or sampleClass2 of Examplel includes a method called sampleMethod2( ) with the same signature as that of delegate, then the same delegate can be used to access both sampleMethod() as well as sampleMethod2( ) Within a class, you can implement an interface method only once. In Example2, interface ITestInterface has a method called sampleMethod(). When sampleClass1 implements ITestInterface it implements sampleMethod() only once. If not, then it will end up in error.

Delegate can implement any When an interface method is method that shares the same implemented, same method name signature as that of the and signature has to be overridden delegate Delegate is mainly used for Interfaces are not used for handling handling events events You need not bother about the other methods available in the class.You are concerned about only the method that matches delegate signature. To access a method using delegate, you need not require any access to the instance of the class where the method is defined When a class implements an interface, though the class requires only one method it has to implement all the methods of the interface To access the method, you need an instance of the class which implements the interface or you need an interface reference pointing to the method implemented by the class

6 7

You can access anonymous You cannot access anonymous methods using delegates methods.Only named methods declared in interface can be

accessed class. 10 When you call a method using a delegate, all the method pointers associated with the delegate will be scanned through before the method execution. This is not a direct method call as you assume. It has a considerable performance overhead.

by

the

implementing

When you are calling a method using interface reference, you are directly accessing the method of the class that implements the interface. This is a direct method call and it doesn't have any overhead.

11

Delegates can wrap methods Accessing sealed types is not of sealed classes.Sealed permissible in interface. classes are those which cannot be inherited. Delegates can wrap any method matching its signature irrespective of which ever class the method belongs to Class can implement any number of interfaces and it should override only the methods belonging to those interfaces

12

13

Delegates can wrap static This provision is not available with methods. Examplel discussed interfaces . above has used the delegate to wrap a static method called sampleMethod() Delegate cannot involve in Interface can inherit other inheritance. interfaces. When a class implements that interface, it has to implement all the methods belonging to the interface and its inherited interfaces as well. Here is an example of an interface inheriting from other interfaces: interface IInterface: IInterface,1 IInterface2 { void sampleMethod1(); void sampleMethod2(); s}

14

Example1: Using Delegate delegate void sampleDelegate( ); class sampleClass1{ static void sampleMethod( ) { Console.WriteLine(Executing sampleMethod of sampleClass1); } }

class sampleClass2 { static void Main( ) { sampleDelegate dele1 = new sampleDelegate(sampleClass1.sampleMethod); dele1(); } } Example2: Using Interface interface ITestInterface{ void sampleMethod( ); } class sampleClass1 : ITestInterface { void sampleMethod( ) { Console.WriteLine(Executing sampleMethod of sampleClass1); } } class sampleClass2 { static void Main( ) { sampleClass1 obj1 = new sampleClass1( ); obj1.sampleMethod( ); } } 3.Difference between Virtual and Abstract keywords in .NET

S.No 1

Virtual If you feel that the derived class may or may not override the base class method, then you will define the base class method as virtual. Consider the following example: namespace Application1 { public class virtualClass { public virtual void virtualMethod(){ Console.WriteLine("Virtual Method.."); } } public class derivedClass:virtualClass{ public override void virtualMethod(){ Console.WriteLine("Overridden .."); } } public class testClass { public static void Main() { virtualClass obj = new

Abstract But if you want to enforce that derived class must override the base class method then you will define the base class method as abstract. namespace Application1 { public abstract class abstractClass { public abstract void abstractMethod(); } public class derivedClass:abstractClass{ public override void abstractMethod(){ Console.WriteLine("Overridden.."); } } public class testClass { public static void Main() { derivedClass obj = new derivedClass(); obj.abstractMethod(); } }

virtualClass(); } obj.virtualMethod(); Output of this derivedClass dObj = new Overridden.. derivedClass(); dObj.virtualMethod(); } } } Output of this code will be: Virtual Method.. Overridden.. 2 Virtual methods need not be compulsorily overridden. In the above example if the derived class does not override the method virtualMethod, then again the code will work.

code

will

be:

Abstract methods should compulsorily be overridden by the derived class. In the above example, if the derivedClass does not override abstractMethod, then during compilation you will get the following error: 'Application1.derivedClass' does not implement inherited abstract member 'Application1.abstractClass.abstrac tMethod()' If you want to define a method as abstract in the base class then the base class should also be marked as abstract. Consider the following example: namespace Application1 { public class abstractClass { public abstract void abstractMethod(); } } In this example, abstractClass has an abstract method. Hence the class in itself has to be marked abstract. But it is not done in the above example. Therefore during compilation, you will end up in the following error: 'Application1.abstractClass.abstrac tMethod()' is abstract but it is contained in nonabstract class 'Application1.abstractClass' Abstract methods have only the signature. It cannot have method body. However the abstract class can include non-abstract methods

To define a base class method to be virtual, you need not include any new definition for the base class. In the earlier example, you can see that the class virtualClass just includes an access modifier followed by the class name. No other additional modifiers are required.

Virtual method can have a method body. In the earlier example, virtualMethod of virtualClass has method

definition like any of the other and these methods can have methods that you define and it method body defined. Consider the is perfectly legal. following example: namespace Application1 { public abstract class abstractClass { public abstract void abstractMethod(){ Console.WriteLine("Abstract method.."); } } } Here you are trying to include method body for an abstract method. This is not permissible. Hence during compilation you will end up in the following error: "'Application1.abstractClass.abstra ctMethod()' cannot declare a body because it is marked abstract" 5 Class containing virtual method can be instantiated. Here is an example: namespace Application1 { public class virtualClass { public virtual void virtualMethod(){ Console.WriteLine("Virtual Method.."); } } Public class testClass { public static void Main() { virtualClass obj = new virtualClass(); obj.virtualMethod(); } } } Output of this code will be: Virtual Method Class containing abstract method cannot be instantiated. It can only be inherited. Consider the following example: namespace Application1 { public abstract class abstractClass { public abstract void abstractMethod(); } public class testClass { public static void Main() { abstractClass obj = new abstractClass(); } } } Here you are trying to create an instance of abstract class. This is not possible. Hence during compilation you will end up in the following error: "cannot create an instance of the abstract class or interface Application1.abstractClass"

Not just methods, virtual Apart from class and method, the modifier can also be used with modifer abstract can be associated properties. with properties, events and indexers.

There is a restriction when using virtual modifer. You cannot use this modifer along with static or abstract or override modifiers.

Abstract modifiers also have a restriction. They cannot be used along with static or virtual or override modifiers.

Reference: http://onlydifferencefaqs.blogspot.in/2012/08/oops-difference-faqs-4.html Functions vs Methods Difference between Functions and Methods S.No 1 2 3 Functions Functions do not have any reference variables All data that is passed to a function is explicitly passed It does not have access controlling i.e.,Function(other than static functions) declares and defines anywhere in the code Function applies to both object oriented and non-object oriented language(procedural language.eg. C, Scripting language eg; JavaScript etc) Methods Methods are called by reference variables It is implicitly passed the object for which it was called It has access controlling i.e.,Method should declare and define in the class only

Method is only applicable to object oriented programming language like C++, C#, Java etc

Summary: A function is just a part of code that executes code and can return something. A method is, in OOP, a function that is bound to a class. As in C# there are no stand-alone functions, every function in C# is a method Reference: http://onlydifferencefaqs.blogspot.in/2012/08/difference-between-functionsand-methods.html Difference between Class and Module Difference between Class and Module S.No 1 Class Meaning: A class is a plan which is used to construct objects (instances of the class). Module Meaning: A module is a loose grouping construct used to group functions and procedures.

Instance Creation: Instances can be created from a class in the form of objects Scope of Class Members: The scope of the members of a class is only for the lifetime of the object Effect on Compilation: Class is compiled into a dll Starting Point of Project: Class explicitly need to mention a starting point of the

Instance Creation: Instances cannot be created from a module in the form of objects Scope of Module Members: The scope of the members of a module exist for the life of the program. Effect on Compilation: Module is compiled into an exe. Starting Point of Project: Module implicitly can be the main starting point in a project through

4 5

Reference: http://onlydifferencefaqs.blogspot.in/2012/08/difference-between-class-andmodule.html Difference between Method Parameters and Method Arguments Difference between Method Parameters and Method Arguments S.No 1 Method Parameters Method parameters get their actual values from the arguments that are specified when the method is invoked. i.e.,"parameters" refer to names Method Arguments Method arguments are itself having a value. i.e.,"arguments" refer to values bound to those names.

Example: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Sample { class Program { public static void Main() { int N1 = 10; int N2 = 20; //N1 and N2 are method arguments int Total = Sum(N1, N2); Console.WriteLine(Total); }

//FNum and SNum are method parameters public static int Sum(int FNum, int SNum) { int Sum = FNum + SNum; return Sum; } } } Note: The arguments must be compatible with the parameter type but the argument name used in the calling code does not have to be the same as the parameter named defined in the method which is clear in the above example Where, FNum and SNum are method parameters, and N1 and N2 are method arguments. Reference: http://onlydifferencefaqs.blogspot.in/2012/08/difference-between-methodparameters.html

You might also like