h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

C# coding Guide

C# coding Guide
Bracing
           Open braces should always be at the beginning of the line after the statement that begins the block. Contents of the brace should be indented by 4 spaces. For example: “case” statements should be indented from the switch statement like this: Braces should never be considered optional. Even for single statement blocks, you should always use braces. This increases code readability and maintainability. Single line statements Single line statements can have braces that begin and end on the same line. It is suggested that all control structures (if, while, for, etc.) use braces, but it is not required.
Spacing
         Spaces improve readability by decreasing code density. Here are some guidelines for the use of space characters within code:

  • Do use a single space after a comma between function arguments. 
  • Do not use a space after the parenthesis and function arguments 
  • Do not use spaces between a function name and parenthesis. 
  • Do not use spaces inside brackets. 
  • Do use a single space before flow control statements 
  • Do use a single space before and after comparison operators 

Naming 
       Follow all .NET Framework Design Guidelines for both internal and external members. Highlights of these include:

  • Do not use Hungarian notation 
  • Do not use a prefix for member variables (_, m_, s_, etc.). If you want to distinguish between local and member variables you should use “this.” in C# and “Me.” in VB.NET. Do use camelCasing for member variables 
  • Do use camelCasing for parameters 
  • Do use camelCasing for local variables 
  • Do use PascalCasing for function, property, event, and class names 
  • Do prefix interfaces names with “I” Do not prefix enums, classes, or delegates with any letter 

Interop Classes 
          Classes that are there for interop wrappers (DllImport statements) should follow the naming convention below:
NativeMethods
           No suppress unmanaged code attribute, these are methods that can be used anywhere because a stack walk will be performed.
UnsafeNativeMethods
            Has suppress unmanaged code attribute. These methods are potentially dangerous and any caller of these methods must do a full security review to ensure that the usage is safe and protected as no stack walk will be performed.
SafeNativeMethods 
           Has suppress unmanaged code attribute. These methods are safe and can be used fairly safely and the caller isn’t needed to do full security reviews even though no stack walk will be performed. All interop classes must be private, and all methods must be internal. In addition a private constructor should be provided to prevent instantiation.
File Organization
        Source files should contain only one public type, although multiple internal classes are allowed
        Source files should be given the name of the public class in the file Directory names should follow the namespace for the class
For example, I would expect to find the public class “System.Windows.Forms.Control” in “System\Windows\Forms\Control.cs"
Classes member should be alphabetized, and grouped into sections (Fields, Constructors, Properties, Events, Methods, Private interface implementations, Nested types) Using statements should be inside the namespace declaration.

Mutable and Immutable string in C#

Mutable and Immutable string in C#

  • Mutable -->means -->change in value
  • Immutable -->means -->No change in value

14 Principles on Total Quality Management

Professional Development – Dr W. Edwards Deming’s 14 Principles on Total Quality Management Dr. Demings’s 14 principles
  • Create a constant purpose toward improvement
  • Adopt the new philosophy
  • Cease dependence on mass inspection
  • Use a single supplier for any one item
  • Improve every process
  • Create training on the job
  • Adopt and institute leadership aimed at helping people do a better job
  • Drive out fear
  • Break down barriers between departments
  • Get rid of unclear slogans
  • Eliminate arbitrary numerical targets
  • Permit pride of workmanship
  • Implement education and self-improvement
  • Make transformation everyone’s job

Event In C#

Event
            Event is a kind of Notification(Information) giving one by one object to perform task. Event handling is not possible without delegate because it is delegate who will be responsible to call Event handler which even is fired.

Partial Class In C#

Partial Class
           we can break a large class code into small pieces by specifying more than one class with same but with partial keyword. In that case those same name classes will not be treated as different classes so when we will made the object of the class, we will get all the method and member for all same name class.

Method Hiding in C#

Method Hiding
            We can predefined the method of parent class in child class by implementing the concept of method hiding. In method hiding the base(parent) class method is predefined in child class by specify new keyword.

Types of delegates in c#

Types of delegates

  • Single cast delegate 
  • Double cast delegate 

Single cast delegate 
  One delegate object can call only one method, is known as single cast delegate.
Double cast delegate 
        In c# One delegate object can call more than one method in sequence ,is known as multicast delegate.

Method Parameters in C#

Method of Parameters

  • Value Parameters.
  • Reference Parameters.
  • Output Parameters.
  • Parameter arrays.  

Value Parameters in C#
     The Value Parameters are used to pass for passing parameters into method by value.
Reference Parameters in C#
        Reference parameters are used to pass parameters into Method by reference.
Output Parameters in C#
         The Output parameters are used to pass results back to the calling Method.
Use of Parameter arrays in C# 
          A Method that can handle variable number of arguments,is known as parameter arrays.Parameter arrays are declared using the keyword param.
Method Overloading in C#
         To create More than one Method with same class name but with the different parameter lists and different definitions,is known as Method Overloading.

Solve Unknown Device Issue

Please follow the step by step procedure

  • Go to Windows Registry. 
  • Click “HKEY_LOCAL_MACHINE” 
  • Click “SYSTEM” 
  • Click “CurrentControlSet” 
  • Click “Services” 
  • Click “USBSTOR” 
  • Check Data of “Start” (in the Right side of the Screen) 
  •        Data is 0x00000003(3) -- USB Port works fine. 
  •        Data is 0x00000004(4) -- USB Port doesn’t work fine.

keyword var and dynamic

var:
            var essentially asks the compiler to figure out the type of the variable based on the expression on the right hand side of the assignment statement. The variable is then treated exactly as if it were explicitly declared as the type of the expression. For example the following two statements are equivalent
var a = "foo";
string a = "foo";
The key to take away here is that "var" is 100% type safe and is a compile time operation.

Dynamic:
        Dynamic is in many ways the exact opposite of var. Using dynamic is essentially eliminating all type safety for that particular variable. It many ways it has no type. When you call a method or field on the variable, the determination on how to invoke that field occurs at runtime. For example
dynamic d = SomeOperation();
d.Foo(); // Will this fail or not?  Won't know until you run the program
The key to take away here is that "dynamic" is not type safe and is a runtime operation.