Wednesday, July 28, 2004

.NET Developer's Guide to Windows Security

Hi,

This is really good book for Security......Now a days I m in love with it.......

A .NET Developer's Guide to Windows Security, by Keith Brown

http://www.pluralsight.com/keith/book/html/book.html

Fundoooooooooooooooooooo......Maja aa gaya......!!!!

Tuesday, July 13, 2004

Funda No.2: What are Static/Type Constructors? Good Question!!

Even I came to know about it Today!!!

Static/Type Constructors

You are already familiar with constructors, which are responsible for setting an object instance to its initial state. In addition to instance constructors, the Microsoft® .NET common language runtime (CLR) also supports type constructors (also known as static constructors, class constructors, or type initializers). A type constructor can be applied to interfaces, classes, and value types. It allows the type to perform any initialization required before any members declared within the type are accessed. Type constructors accept no parameters and always have a return type of void. A type constructor only has access to a type's static fields and its usual purpose is to initialize those fields. A type's constructor is guaranteed to run before any instance of the type is created and before any static field or method of the type is referenced.
Many languages (including C#) automatically generate type constructors for any types you define. However, some languages will require you to implement the type constructors explicitly.

To understand type constructors, examine the following type (defined in C#):

class AType {
static int x = 5;
}

When this code is built, the compiler automatically generates a type constructor for AType. This constructor is responsible for initializing the static field x to the value 5. If you're using ILDasm, you can easily spot type constructor methods because they have a name of .cctor (for class constructor).
In C#, you can implement type constructors yourself by defining a static constructor method in your type. The use of the static keyword makes the constructor a type constructor rather than an instance constructor. Here is a very simple example:

class AType {
static int x;

static AType() {
x = 5;
}
}

This type definition is identical to the previous one. Note that a type constructor must never attempt to create any instances of its own type, and the constructor must not reference any of the type's nonstatic members.
Finally, if you give the C# compiler the following code, it generates a single type constructor method.

class AType {
static int x = 5;

static AType() {
x = 10;
}
}

This constructor first initializes x to 5 and then initializes x to 10. In other words, the resulting type constructor generated by the compiler first contains the static field initialization code, which is then followed by the code in your type constructor method.


Kyon Kaisee rahi.........

Bye Deepak.....Watch out for funda No.3............

Funda No.1 : Sealed Modifier in C# - Really Good

Hi Guys,

Look into it.....

Funda No.1 :

In Beta 1, the Sealed modifier, when used on method overrides, yielded a compiler error: "The modifier 'sealed' is not valid for this item." In Beta 2, the compiler recognizes the Sealed modifier.

Sample Code Snippet:
public class B : A
{
public B()
{
}
sealed public override string Method1()
{
return "Override";
}
}

Use of the Sealed modifier, in conjunction with the override method, will prevent anything classes derive from class B from further overriding Method1(), which originally was provided by the base class A.

So Hows That....