What is .NET?
Namespaces in C#
Namespaces allow you to create a system to organize your
code. A good way to organize your namespaces is via a
hierarchical system.
Introduction
This article bring in you to C# Namespaces. In this article,
my objectives are as follows:
The example:
namespace arun.CSharp.Namespaces
{
public class Hello
{
public string GetMessage()
{
return "Hello, world";
}
}
}
Namespaces
are
hierarchical,
and
the
name
arun.CSharp.Namespaces is actually shorthand for
defining a namespace named arun that contains a
namespace named CSharp that itself contains a
namespace named Namespaces, as in:
namespace arun
{
namespace CSharp
{
namespace Namespaces
{....}
}
}
What is an Assembly
An assembly is a file that is automatically generated by
the compiler upon successful compilation of every .NET
application. It can be either a Dynamic Link Library or an
executable file. It is generated only once for an
application and upon each subsequent compilation the
assembly gets updated. However, a basic knowledge
about this topic will help you to understand the
architecture behind a .NET application.
INDEXER
Boxing/ UnBoxing
C# allows us to convert a Value Type to a Reference Type,
and back again to Value Types . The operation of
Converting a Value Type to a Reference Type is called
Boxing and the reverse operation is called Unboxing.
Boxing
1: int Val = 1;
2: Object Obj = Val; //Boxing
UnBoxing
1: int Val = 1;
2: Object Obj = Val; //Boxing
3: int i = (int)Obj; //Unboxing
The first two line shows how to Box a Value Type . The
next line (int i = (int) Obj) shows extracts the Value Type
from the Object . That is converting a value of a Reference
Type into a value of a Value Type. This operation is called
UnBoxing.
What Is DLL
A DLL file is a resource within the Windows operating
system that contains code and data related to the
functionality of one or more applications. These files,
which may have the file extension .dll or other file
extensions, have been a major building block for the
Windows operating system and Windows programs since
the early MS-DOS versions of Microsofts computer
Anonymous method
Anonymous method is an inline un-named method in the
code.
>> It is created using the delegate keyword end doesnt
require name end return type and
Hence we can consider an anonymous method has only
body without name end return type.
Syntax:
delegate ( [argnfo] )
{ //statement(s) }
Commands
Return type
Insert,Update,Delete,... int
Select
SqlDataReader
Aggregate commands
Object
Optimistic locking
As the name suggests optimistic it assumes that
multiple transaction will work without affecting each
other. In other words no locks are enforced while doing
optimistic locking. The transaction just verifies that no
other transaction has modified the data. In case of
modification the transaction is rolled back.
How does optimistic lock work?
You can implement optimistic locking by numerous ways
but the fundamental to implement optimistic locking
remains same. Its a 5 step process as shown below: Record the current timestamp.
Start changing the values.
Before updating check whether anyone else has
changed the values by checking the old time stamp and
new time stamp.
If its not equal rollbacks or else commit.
When to use?
Reads Writes
Allowed Allowed
Shared lock
No
Exclusive
No
Update lock
Read phase
Yes
No
Manipulating phase
Yes
No
Update phas
No
No
NA
Schema locks
No
Bulk update
locks
Table
Table
level No level No
No