Class
|
Structure
|
Reference type
|
Value type
|
Supports inheritance
|
Does not support inheritance
|
Has default constructors
|
Does not have default constructors but
parameterized constructors are allowed
|
Wednesday, 3 July 2019
Classes and Structures
Procedures and Functions
|
Procedures
|
Functions
|
|
Procedure
can return zero on N values
|
Functions
can return only single value
|
|
Returning
a value is not mandatory
|
Returning
a single value is mandatory
|
|
Can
have both input and output parameters
|
Can
have only input parameters
|
|
Can
select as well as other DML, Data Manipulation Language (INSERT, UPDATE,
DELETE,) statements
|
Can
only do select statement
|
|
Function
can be called from procedure
|
Procedure
cannot be called from functions
|
|
Try
catch block can be used to handle the errors
|
Try
catch block cannot be used in functions
|
|
Procedures
cannot be utilized in select, where, having statement
|
Whereas
functions can be utilized in select, where, having statement
|
Monday, 19 March 2018
My Other Blogs
Angular2/4/5 https://andrewgoelangular.blogspot.in/
AngularJS https://andrewgoelangularjs.blogspot.in/
C-Sharp https://andrewgoelcsharp.blogspot.in/
HTML + CSS https://andrewgoelcss.blogspot.in/
JavaScript https://andrewgoeljavascript.blogspot.com/
Jquery https://andrewgoeljquery.blogspot.com/
Learning Habbit https://learnmoreearnmore.blogspot.in/
Managerial https://andrewgoelmanagerial.blogspot.in/
SQL https://andrewgoelsql.blogspot.com/
AngularJS https://andrewgoelangularjs.blogspot.in/
C-Sharp https://andrewgoelcsharp.blogspot.in/
HTML + CSS https://andrewgoelcss.blogspot.in/
JavaScript https://andrewgoeljavascript.blogspot.com/
Jquery https://andrewgoeljquery.blogspot.com/
Learning Habbit https://learnmoreearnmore.blogspot.in/
Managerial https://andrewgoelmanagerial.blogspot.in/
SQL https://andrewgoelsql.blogspot.com/
Monday, 3 February 2014
Abstract, Sealed, Static, Partial - Classes
Class Types:
1) Abstract class
2) Sealed Class
3) Static Class
4) Partial Class
-----------------------------------------
A-- Abstract
S-- Sealed
S--Static
ASS is order by name
Abstract Class
Sealed Class
{
protected virtual void F() { Console.WriteLine("X.F"); }
protected virtual void F2() { Console.WriteLine("X.F2"); }
}
class Y : X
{
sealed protected override void F() { Console.WriteLine("Y.F"); }
protected override void F2() { Console.WriteLine("X.F3"); }
}
class Z : Y
{
// Attempting to override F causes compiler error CS0239.
// protected override void F() { Console.WriteLine("C.F"); }
// Overriding F2 is allowed.
protected override void F2() { Console.WriteLine("Z.F2"); }
}
Static Class
a special ability to implement the functionality of a single class into multiple files and all these files are combined into a single class file when the application is compiled. A partial class is created by using a partial keyword
1) Abstract class
2) Sealed Class
3) Static Class
4) Partial Class
-----------------------------------------
A-- Abstract
S-- Sealed
S--Static
ASS is order by name
Keyword
|
Can be instantiated(object)
|
Can be inherited
|
Abstract
|
NO
|
YES
|
Sealed
|
YES
|
NO
|
Static
|
NO
|
NO
|
Abstract Class
- It only represents the base class and thus has be inherited for its use.
- Object can NOT be created. can NOT be instantiated.
- Abstract class and methods can NOT be sealed ( class which can not be inherited).
- Abstract methods can NOT be private.
- Abstract methods can NOT be virtual ( by default they are virtual).
- Abstract class and methods can NOT be static.
- Abstract method definition can be given only inside a Abstract class. In non abstract class no abstract method can be defined.
- Can have either abstract method or non-abstract methods.
- Abstract method do not have any implementation of methods but has to be provided the same in the derived class.
- Abstract class may contain NO abstract method at all.
- Abstract methods has to be override in derived class.
- Derived class has to implement all abstract methods of abstract class.
abstract class absClass
{
public abstract int abstractMethod(int Num1, int Num2);
}
public override int abstractMethod(int Num1, int Num2)
{
return Num1 * Num2;
}
- Restrict inheritance. can NOT be inherited. Its just to take away the inheritance feature.
- Structs are sealed in nature.
- NO restriction on object creation. sealed class can be instantiated.
- If you make a sealed a method / property that overrides a virtual method /property it will get prevented from further overriding.
- Best use of sealed class is when your sealed class has static members (How?).
{
protected virtual void F() { Console.WriteLine("X.F"); }
protected virtual void F2() { Console.WriteLine("X.F2"); }
}
class Y : X
{
sealed protected override void F() { Console.WriteLine("Y.F"); }
protected override void F2() { Console.WriteLine("X.F3"); }
}
class Z : Y
{
// Attempting to override F causes compiler error CS0239.
// protected override void F() { Console.WriteLine("C.F"); }
// Overriding F2 is allowed.
protected override void F2() { Console.WriteLine("Z.F2"); }
}
Static Class
- Static class must have all methods and variables as static.
- Even in static class only static constructor can be called and NO instance constructor allowed.
- can NOT be instantiated.
- static class is Sealed(can not be inherited) by default.
- Static class can NOT be abstract class ( as it can not be inherited).
- Static class can only inherit system.object class as system.object class is the base class for every class.
- Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.
- Use a static class to contain methods that are not associated with a particular object.
a special ability to implement the functionality of a single class into multiple files and all these files are combined into a single class file when the application is compiled. A partial class is created by using a partial keyword
SOAP and REST
|
SOAP
|
REST
|
|
Only XML format is allowed for data transfer.
|
Multiple format like Plain Text, XML, JSON HTML
|
|
Stateless by default, but it’s possible to make a SOAP API stateful.
|
Stateless (no server-side sessions).
|
|
While SOAP supports SSL (just like REST) it also supports WS-Security
which adds some enterprise security features.
|
Less Secure
|
|
Requires more bandwidth and computing power
|
Requires fewer resources.
|
WCF and ASP.net Services
Const
|
Read-only
|
A constant member is defined at compile time and cannot be changed at runtime.
|
read-only member can be initialized at runtime, in a constructor as well being able to be initialized as they are declared
|
They must be initialized as they are declared
|
Not implicitly static (only single object ) and has to explicitly made static
|
Subscribe to:
Posts (Atom)