Posts

Showing posts from July, 2012

How to enable hidden administrator account in windows 7 - Vista

Image
First you’ll need to open a command prompt in administrator mode by right-clicking and choosing “Run as administrator” (or use the Ctrl+Shift+Enter shortcut from the search box) Now type the following command: net user administrator /active:yes  You should see a message that the command completed successfully. Log out, and you’ll now see the Administrator account as a choice.

.NET Framwork Tools

Image
Develop, configure, and deploy applications by using Microsoft .NET Framework technologies http://msdn.microsoft.com/en-us/library/d9kh6s92(v=vs.90) [MSDN LINKS] Configuration and Deployment Tools Debugging Tools Security Tools General Tools SDK Command Prompt Assembly Linker (Al.exe) ASP.NET Compilation Tool (Aspnet_compiler.exe) ASP.NET Merge Tool (Aspnet_merge.exe) ASP.NET Browser Registration Tool (Aspnet_regbrowsers.exe) ASP.NET IIS Registration Tool (Aspnet_regiis.exe) ASP.NET SQL Server Registration Tool (Aspnet_regsql.exe) Windows Forms ActiveX Control Importer (Aximp.exe) Code Access Security Policy Tool (Caspol.exe) Code Generation Tool (SqlMetal.exe) Software Publisher Certificate Test Tool (Cert2spc.exe) Certificate Manager Tool (Certmgr.exe) Certificate Verification Tool (Chktrust.exe) Runtime Debugger (Cordbg.exe) CorFlags Conversion Tool (CorFlags.exe) Assembly Binding Log Viewer (Fuslogvw.exe) Global Assembly Cache Tool (Gacutil.exe) MSIL Assembler (Ilasm.exe

Partial Keyword in C#

A partial method has its signature defined in one part of a partial type, and its implementation defined in another part of the type. Partial methods enable class designers to provide method hooks, similar to event handlers, that developers may decide to implement or not. If the developer does not supply an implementation, the compiler removes the signature at compile time. The following conditions apply to partial methods: Signatures in both parts of the partial type must match. The method must return void. No access modifiers or attributes are allowed. Partial methods are implicitly private. The following example shows a partial method defined in two parts of a partial class: namespace PM { partial class A { partial void OnSomethingHappened( string s); } // This part can be in a separate file. partial class A { // Comment out this method and the program // will still compile. partial void OnSomethingHapp

Override in c#

The  override  modifier is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event. In this example, the  Square  class must provide an overridden implementation of  Area  because  Area  is inherited from the abstract  ShapesClass : abstract class ShapesClass { abstract public int Area(); } class Square : ShapesClass { int side = 0; public Square( int n) { side = n; } // Area method is required to avoid // a compile-time error. public override int Area() { return side * side; } static void Main() { Square sq = new Square(12); Console.WriteLine( "Area of the square = {0}" , sq.Area()); } interface I { void M(); } abstract class C : I { public abstract void M(); } } // Output: Area of the square = 144 An  override  method provides a new implementation

DllImportAttribute Class in C#

Indicates that the attributed method is exposed by an unmanaged dynamic-link library (DLL) as a static entry point. Namespace:    System.Runtime.InteropServices Assembly:    mscorlib  (in mscorlib.dll) You can apply this attribute to methods. The  DllImportAttribute  attribute provides the information needed to call a function exported from an unmanaged DLL. As a minimum requirement, you must supply the name of the DLL containing the entry point. You apply this attribute directly to C# and C++ method definitions; however, the Visual Basic compiler emits this attribute when you use the  Declare  statement. For complex method definitions that include  BestFitMapping ,  CallingConvention ,  ExactSpelling ,  PreserveSig ,  SetLastError , (MSDN LINK)  or   ThrowOnUnmappableChar   (MSDN LINK)   fields, you apply this attribute directly to Visual Basic method definitions. Note    JScript does not support this attribute. You can use C# or Visual Basic wrapper classes to acce

Extern Keyword in C#

The  extern  modifier is used to declare a method that is implemented externally. A common use of the  extern  modifier is with the  DllImport  attribute when you are using Interop services to call into unmanaged code. In this case, the method must also be declared as  static , as shown in the following example: [DllImport("avifil32.dll")] private static extern void AVIFileInit(); NOTE: The  extern  keyword can also define an external assembly alias, which makes it possible to reference different versions of the same component from within a single assembly. For more information, see  extern alias (C# Reference) . It is an error to use the  abstract (C# Reference)  (MSDN LINK)  and  extern  modifiers together to modify the same member. Using the  extern  modifier means that the method is implemented outside the C# code, whereas using the  abstract  modifier means that the method implementation is not provided in the class. NOTE: The  extern  keyword has more limited

Yield in C#

The  yield  keyword signals to the compiler that the method in which it appears is an iterator block. The compiler generates a class to implement the behavior that is expressed in the iterator block. In the iterator block, the  yield  keyword is used together with the  return  keyword to provide a value to the enumerator object. This is the value that is returned, for example, in each loop of a  foreach  statement. The  yield  keyword is also used with  break  to signal the end of iteration. For more information about iterators, see  Iterators (C# Programming Guide) .(MSDN LINK) The following example shows the two forms of the yield statement. public static IEnumerable Power( int number, int exponent) { int counter = 0; int result = 1; while (counter++ < exponent) { result = result * number; yield return result; } }

Out Keyword in C#

The  out  keyword causes arguments to be passed by reference. This is like the  ref  keyword, except that  ref  requires that the variable be initialized before it is passed. To use an  out  parameter, both the method definition and the calling method must explicitly use the  out  keyword. For example: class OutExample { static void Method( out int i) { i = 44; } static void Main() { int value; Method( out value); // value is now 44 } } Although variables passed as out arguments do not have to be initialized before being passed, the called method is required to assign a value before the method returns. Although the ref and out keywords cause different run-time behavior, they are not considered part of the method signature at compile time. Therefore, methods cannot be overloaded if the only difference is that one method takes a ref argument and the other takes an out argument. The following code, for example,

Ref Keyword in C#

The  ref  keyword causes arguments to be passed by reference. The effect is that any changes to the parameter in the method will be reflected in that variable when control passes back to the calling method. class RefExample { static void Method( ref int i) { i = 44; } static void Main() { int val = 0; Method( ref val); // val is now 44 } }

Params in C#

The params keyword lets you specify a method parameter that takes a variable number of arguments. You can send a comma-separated list of arguments of the type specified in the parameter declaration, or an array of arguments of the specified type. You also can send no arguments. No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration. public class MyClass { public static void UseParams( params int [] list) { for ( int i = 0; i < list.Length; i++) { Console.Write(list[i] + " " ); } Console.WriteLine(); } public static void UseParams2( params object [] list) { for ( int i = 0; i < list.Length; i++) { Console.Write(list[i] + " " ); } Console.WriteLine(); } static void Main() { // You can send a comma-separated l

Lock Statement in C#

The  lock  keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock. This statement takes the following form Object thisLock = new Object(); lock (thisLock) { // Critical code section. } For more information, see  Thread Synchronization (C# Programming Guide) .(MSDN link) The lock keyword ensures that one thread does not enter a critical section of code while another thread is in the critical section. If another thread tries to enter a locked code, it will wait, block, until the object is released. The section Threading (C# Programming Guide)(MSDN LINK) discusses threading. The lock keyword calls Enter at the start of the block and Exit at the end of the block. In general, avoid locking on a public type, or instances beyond your code's control. The common constructs  lock (this) ,  lock (typeof (MyType)) , and lock ("myLock")  violate this guideli

Fixed Statement in c#

The fixed statement prevents the garbage collector from relocating a movable variable. The fixed statement is only permitted in an unsafe context. Fixed can also be used to create fixed size buffers. The fixed statement sets a pointer to a managed variable and "pins" that variable during the execution of the statement. Without fixed, pointers to movable managed variables would be of little use since garbage collection could relocate the variables unpredictably. The C# compiler only lets you assign a pointer to a managed variable in a fixed statement. unsafe static void TestMethod() { // assume class Point { public int x, y; } // pt is a managed variable, subject to garbage collection. Point pt = new Point(); // Using fixed allows the address of pt members to be // taken, and "pins" pt so it isn't relocated. fixed ( int * p = &pt.x) { *p = 1; } } You can initialize a pointer with the addr

Throw statement in c#

Usually the  throw  statement is used with try-catch or try-finally statements. You can also rethrow a caught exception using the  throw  statement public class ThrowTest2 { static int GetNumber( int index) { int [] nums = { 300, 600, 900 }; if (index > nums.Length) { throw new IndexOutOfRangeException(); } return nums[index]; } static void Main() { int result = GetNumber(3); } } /* Output: The System.IndexOutOfRangeException exception occurs. */

Pointers in C# [ -> Operator Reference ]

The -> operator combines pointer dereferencing and member access. An expression of the form, x->y (where x is a pointer of type T* and y is a member of T ) is equivalent to, (*x).y The -> operator can be used only in code that is marked as unsafe (msdn link). The -> operator cannot be overloaded. // compile with: /unsafe //To compile unsafe code, you must specify the /unsafe compiler option.  //Unsafe code is not verifiable by the common language runtime. struct Point { public int x, y; } class MainClass12 { unsafe static void Main() { Point pt = new Point(); Point* pp = &pt; pp->x = 123; pp->y = 456; Console.WriteLine( "{0} {1}" , pt.x, pt.y); } } /* Output: 123 456 */ More references about unsafe and c# helpful keywords are below... (source :msdn) Access Modifiers abstract  const event extern override readonly seal