C# Fundamentals


Annontations of C# Fundamentals: In this blog I have written breifly about each of the fundamental features of C# Programming language, I feel the annotations listed below highlights some of the fundamental features of every .NET developer should know before he starts developing professional software. I have tried to keep them very concise  so that the developer need not have to spend more time reading them than using them in the software development. These annontations highlights help every developer understand a broad picture about C#.NET from 2.0 to 4.0 version.

This will be one of the post of the C# Annontation series being published and continued. I hope this blog makes your reading interesting and enjoyable. (Directly go  to first Annotation)

Annotation 1. user-defined types .Net

Annotation 2 the enumerations

Annotation 3. Define Stream class in .Net Explain with an example using C#.Net.

Annotation 4. Explain common stream types in .Net

Annotation 5. Explain how to compress data with a compression Stream.

Annotation 6. Explain how to Throw and Catch Exceptions in C#.Net

Annotation 7.Explain how should we use StringBuilder class instead of the String class.

Annotation 8. Explain why we should close and dispose resources in a finally block instead of a catch block?

Annotation 9. What is an interface in Net ? Explain with an example using C#.Net?

Annotation 10. Define most commonly used interfaces in Net Framework.

Annotation 11. Explain with an example how to create and consume a Generic type.

Annotation 12. Type Forwarding in .Net.

Annotation 13. SOAPFormatter:

Annotation 23. Explain XML Serialization.

Annotation 24. Explain XML Serialization of an object in C#.

Annotation 25. XML Deserialization of an object in C#.Net.

Annotation 26.  Code access security. Describe the purpose of CAS.

Annotation 27. What is Permission? What is a Permission Set?

Annotation 28. comparison of strings in C#

Annotation 30. The Access controlling options of a class member are as follows

Annotation 31. characteristics of System.Object

Annotation 32. the interoperability scenarios.

Annotation 33. response files & its characteristics.

Annotation 34. characteristics of an assembly

Annotation 35. types of assemblies

Annotation 36. the config file of assembly.

Annotation 37. the publisher policy.

Annotation 38. publisher Policy element

ANNOTATION 39. System.Object

Annotation 40. The CLR requires all objects to be created using the new operator.

Annotation 41. Is operator.

Annotation 42. using directive

Annotation 43. namespace

Annotation 44. The /checked+ compiler switch

Annotation 45. checked and unchecked operators

Annotation46. checked and unchecked statements

Annotation 47. system.valuetype

Annotation 48. differences between value type and reference type.

Annotation 49. .NET type and its members.

Annotation50. Member accessiblity

Annotation 51.Partial keyword

Annotation 52. Explain the namespaces in which .NET has the data functionality class.

Annotation 53. Overview of ADO.NET architecture.

Annotation 54.  a dataset object.

Annotation 55.  the ADO.NET architecture.

Annotation 56. the steps to perform transactions in .NET

Annotation 57. Define connection pooling

Annotation 58. Steps to enable and disable connection pooling?

Annotation 59. explain enabling and disabling connection pooling.

Annotation 60. What is the relation between Classes and instances?

Annotation 61.Difference between dataset and datareader.

Annotation 62. What are command objects?

Annotation63. the use of data adapter.

Annotation 64.  The basic methods of Dataadapter

Annotation 65. the steps involved to fill a dataset.

Annotation 66. Identifying changes made to dataset since it was loaded.

Annotation 67. Steps to add/remove row’s in “DataTable” object of “DataSet”

Annotation 68. the basic use of “DataView” and its methods.

Annotation 69. To load multiple tables in a DataSet.

Annotation 70. applications of CommandBuilder

Annotation 71. Define connected and disconnected data access in ADO.NET

Annotation 72. Describe CommandType property of a SQLCommand in ADO.NET.

Annotation 73. list the debugging windows available.

Annotation 74. Break mode:

Annotation 75. the options for stepping through code

Annotation 76. define a Breakpoint

Annotation 77. Define Debug and Trace Class.

Annotation 78. What are Trace switches?

Annotation 79. configuration of trace switches in the application’s .config file.

Annotation 80. What is an Event?

Annotation 81. Define Delegate.

Annotation 82. What is the purpose of AddHandler keyword?

Annotation 83. exceptions handling in CLR

Annotation 84. create and throw a custom exception.

Annotation 85. difference between Localization and Globalization

Annotation 86. Define Unicode

Annotation 87. Steps to generate a resource file

Annotation 88. Implementation of globalization and localization in the use interface in .NET.

Annotation 89. the functions of the Resource Manager class

Annotation 90. Explain preparation of culture-specific formatting in .NET.

Annotation 91. Define XCopy

Annotation 92. Explain visual INHERITANCE OF windows forms.

Annotation 93. Explain the lifecycle of the form.

Annotation 94. Explain the steps to create menus

Annotation 95. Anchoring a control and Docking a control

Annotation 96. Define ErrorProvider control.

Annotation 97. Explain building a composite control

Annotation 98. Explain the ways to deploy your windows application ?

Annotation 99. Explain 3 types of configuration files in windows application in .NET?

Annotation 100. What are the ways to optimize the performance of a windows application?

Annotation 101. List out difference between the Debug class and Trace class.

Annotation 102. Name three test cases you should use in unit testing?

Annotation 103. Explain the finally statement in C#.NET.

Annotation 104. the steps to create and implement Satellite Assemblies.

Annotation 105. Explain the purpose of ResourceManager class. name the namespace that contains it.

Annotation 106. Explain the purpose of CultureInfo class. What namespace contains it?

Annotation 107. Explain steps to prepare culture-specific formatting.

Annotation 108. the Steps to implement localizability to the user interface?

Annotation 109. Define Trace Listeners and Trace Switches?

Annotation 110. Explain tracing with an example using C#.NET.

Annotation 111. Define CLR triggers.

Annotation 112. Difference between an interface and abstract class

Annotation 113. Difference between System.String and System.StringBuilder classes.

Annotation 114. List different ways to deploy an assembly.

Annotation 115. Define Satellite Assembly.

Annotation 116. Declare a custom attribute for the entire assembly.

Annotation 117. Explain abstraction in C#.NET.

Annotation 118. Explain encapsulation usage in C#.

Annotation 119. Differentiate between instance data and class data

Annotation 120. the significance of static method

Annotation 121. The application of boxing and unboxing.

Annotation 122. Explain calling a native function exported from a DLL?

Annotation 123. Simulation of optional parameters to COM functions.

Annotation 124. Sealed class in C#.NET

Annotation 125. generics in C#.NET

Annotation 126. marking a method obsolete

Annotation 127. System.Environment class in C#.NET.

Annotation 128. implementation of synchronization in C#.

Annotation 129. the advantages of CLR procedure over T-SQL procedure.

Annotation 130. comparison of C# Generics and C++ Templates.

Annotation 131. an object pool in .NET

Annotation 132. Exceptions in .NET

Annotation 133. Custom Exceptions in .NET

Annotation 134. delegates and its application

Annotation 135.Explain implementation of Delegates in C#

Annotation 136. the difference between Finalize() and Dispose()

Annotation 137. the XmlSerializer  and its use in ACL permissions.

Annotation 138. circular references.

Annotation 139. Explain steps to add controls dynamically to the form.

Annotation 140. Extender provider components and its use.

Annotation 141. the configuration files in .Net.

Annotation 142. Describe the accessibility modifier “protected internal” in C#.

Annotation 143. the difference between Debug.Write and Trace.Write

Annotation 144. Explain the use of virtual, sealed, override, and abstract.

Annotation 145. Benefits of a Primary Interops Assembly (PIA)

Annotation 146. Explain the use of static members with example.

Annotation 147. How to achieve polymorphism in C#.NET?

Annotation 148. Define Code-Access security

Annotation 149. Define Role-based security?

Annotation 150. Explain steps to deploy an XML web service

Annotation 151. Explain the namespaces in which .NET has the data functionality class.

Annotations:

Annotation 1. user-defined types .Net

Public class Student
{
int age;
string name;
public Student(int _age, string _name)
{
age=_age;
name=_name;
}
public int Age
{
get{return age;}
set{age=value;}
}
public String Name
{
get{return name;}
set{name=value;}
}
}

Student is a user defined type which stores age and name of a student.

Annotation 2 the enumerations

An enumeration is a special type of collection in the .NET Framework that can contain lots of named constants.

e.g.

public enum IDSTablesType
{
SYSTEM, BOARD, CHIP, BLOCK, REGGROUP,REGISTER
}

Annotation 3. Define Stream class in .Net Explain with an example using C#.Net.

The Stream class gives a view of various types of input and output. Streams involve three fundamental operations:

a. Read: transfer of data from stream into a data structure.
b. Write: transfer of data from a data structure into stream.
c. Seeking: querying and updating the current position within the stream.

Streams are a medium to read and write data to and from memory, file or other objects.

e.g.:

System.IO.StreamReader file=new StreamReader(@”abc.txt”)
string temp=file.ReadToEnd();
file.close();

Annotation 4. Explain common stream types in .Net

a. FileStream: is to read from, write to, open, and close files on a file system. FileStream objects support random access to files using the Seek method.

b. MemoryStream: It creates streams that have memory as a backing store instead of a disk or a network connection. Memory streams can reduce the need for temporary buffers and files in an application.

c. StreamReader: It is meant for character input , whereas the Stream class is meant to perform byte input and output. StreamReader is basically used for reading lines of text from a text file.

d. StreamWriter: It is meant for character output instead of byte output.

Annotation 5. Explain how to compress data with a compression Stream.

Compression streams write to another stream. The compression streams take in data like any other stream. But then it writes it in compressed format to another stream.

Steps to compress data using compression stream:

a. Open the file and create a new file for the compressed version

FileStream orgFile = File.OpenRead(@”C:\abc.bak”);
FileStream compFile = File.Create(@”C:\abc.gzip”);

b. Compression stream wraps the outgoing stream with the compression stream.

GZipStream compStream = new GZipStream(compFile, CompressionMode.Compress);

c. Write from the original file to compression stream

int wrtTxt = orgFile.ReadByte();
while (wrtTxt != -1)
{
compStream.WriteByte((byte) wrtTxt);
wrtTxt = orgFile.ReadByte();
}

Annotation 6. Explain how to Throw and Catch Exceptions in C#.Net

try
{
throw new Exception(“Caught Error”);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}

Annotation 7.Explain how should we use StringBuilder class instead of the String class.

Whenever any of the methods of String class is used to modify the string, a new object is created and memory is allocated to that object. If there are repeated modifications on the string, the performance can get hampered making it costly. Whereas, the StringBuilder class can be used for modifications over and over again without creating a new object. So one situation where a StringBuilder class might be of use is, if we are manipulation string in a loop.

Annotation 8. Explain why we should close and dispose resources in a finally block instead of a catch block?

Catch block gets called only when an exception occurs or is explicitly thrown but we need to release our resources in either case (task failure or success). Finally block gets called irrespective of what happens in try. For example: we fetch data from database. In this case the first step would be creating a connection in order to access the database. Once our work is done successfully or if our logic crashes we need to end the connection so we write it in a finally block.

Annotation 9. What is an interface in Net ? Explain with an example using C#.Net?

Interface contains only the declaration for its abstract members (events, methods, properties). Any implementation must be placed in class that implements them. Interface is the only way that lets us the implement multiple inheritance. The interface cannot contain constants, data fields, constructors, and destructors.

interface ITest
{
string Text
{
get;
set;
}
string printString();

Annotation 10. Define most commonly used interfaces in Net Framework.

IComparable: It is implemented by types for ordering and sorting. The implementation types must implement one single method i.e. CompareTo.

IDisposable:This is implemented to manage release of unmanaged resources from memory. The garbage collector acts on its own and hence the Dispose method is used to call the garbage collector to free unmanaged resources through this interface.

IConvertible: It is implemented to convert value of the implementing type into another CLR compatible type. If the conversion fails then an invalidcastexception is thrown.

ICloneable: Allows creating objects of a class having same values as another instance using the Clone method.

IEquatable: Implemented to create type specific methods to know the equality between various objects.

IFormattable: Implemented to convert object into string representations. Objects can define their own specific string representation through this interface’s ToString() method.

Annotation 11. Explain with an example how to create and consume a Generic type.

public static object CreateMethod(Type generic, Type innerType, params object[] args)
{
System.Type type = generic.MakeGenericType(new System.Type[] { innerType });
return Activator.CreateInstance(type, args);
}
To use it:
CreateMethod(typeof(List<>), typeof(string));

Annotation 12. Type Forwarding in .Net.

Type forwarding is a technique to move types from one assembly to another without the clients needing to recompile the assemblies.

Steps:

Assuming we are moving a type called Student from Assembly A to Assembly B

a. Remove definition of Student in Assembly A and replace it with TypeForwardedTo attribute. E.g.: [assembly: TypeForwardedTo(type OF (AssemblyA.Student)))]

b. Put the definition of Student in AssemblyB.

c. Rebuild both assemblies and deploy.

Annotation 13. SOAPFormatter:

It is an xml based serialization technique which is used to serialize and deserialize objects and data across networks.

using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Soap;

[Serializable]
public class A:ISerializable
{
public void main()
{
A MyObjList = new A();
FileStream fStream = new FileStream(“test.xml”, FileMode.Create);
SoapFormatter serformatter = new SoapFormatter();
serformatter.Serialize(fStream, MyObjList);
fStream.Close();
}
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue(“Test”, TestString);
info.AddValue(“Object1”, object1);
info.AddValue(“Object2”, object2);
}
}

Annotation 23. Explain XML Serialization.

Serialization allows persisting objects. XML serializations stores objects in form of XML which has become a storage standard. The main advantage with XML is that it is platform, language independent. Any other software can practically read XML and write data, hence interoperability is an added advantage with XML serialization. XML also has the power to show relationships between various objects which is also advantageous when performing serialization of objects along with other related objects.

Annotation 24. Explain XML Serialization of an object in C#.

a. Use the namespace “System.Xml.Serialization”.

b. Create a class whose object is to be serialized

c. Create an object of the class for example: Class1 c = new Class1();

d. Set the properties of the Class1 using the object c.

 c.name=”abc”; c.age=10;

e. Create an instance of XmlSearializer : XmlSerializer x = new XmlSerializer(c.GetType()); TextWriter txtWrite = new StreamWriter( @”c:\test.xml” );

f. Use the xmlserializer instance to serialize the object to xml
x.Serialize(txtWrite,c);

g. Execute the project to verify

Annotation 25. XML Deserialization of an object in C#.Net.

XmlSerializer srl = new XmlSerializer(typeof(Class1));
FileStream fStream = new FileStream(filename, FileMode.Open);
XmlReader rdr = new XmlTextReader(fStream);
Class1 cls1;
cls1 = (Class1) srl.Deserialize(rdr);

Annotation 26. Code access security. Describe the purpose of CAS.

Code access security is a mechanism to help protect computer systems from malicious code, to run code from unknown origins with protection. It allows code to be trusted to different levels based on where its coming from and its identity. It reduces the chances of your code being misused for performing malicious tasks or operations. It reduces the security vulnerabilities that a piece of code may have as well. CAS defines the permissions and access rights the code has.

Annotation 27. What is Permission? What is a Permission Set?

Permission is a rule to enforce restriction on a piece of managed code. This is used by runtime in order to implement its mechanism. Code can request for permissions or runtime can grant permissions on the basis of the characteristics of the code. It also depends on how much the code can be trusted. There are 3 types of permissions:

a. Code access permissions
b. Identity permissions
c. Role-based security permissions

Permission set is a set of all the permissions that can be assigned to a code group.

Annotation 28. comparison of strings in C#

In the past, you had to call .ToString() on the strings when using the == or != operators to compare the strings’ values. That will still work, but the C# compiler now automatically compares the values instead of the references when the == or != operators are used on string types. If you actually do want to compare references, it can be done as follows: if ((object) str1 == (object) str2) { … } Here’s an example showing how string compares work: 
using System;
public class StringTest
{
public static void Main(string[] args)
{
Object nullObj = null; Object realObj = new StringTest();
int i = 10;
Console.WriteLine(“Null Object is [” + nullObj + “]\n”
+ “Real Object is [” + realObj + “]\n”
+ “i is [” + i + “]\n”);
// Show string equality operators
string str1 = “foo”;
string str2 = “bar”;
string str3 = “bar”;
Console.WriteLine(“{0} == {1} ? {2}”, str1, str2, str1 == str2 );
Console.WriteLine(“{0} == {1} ? {2}”, str2, str3, str2 == str3 );
}
}
Output:

Null Object is []
Real Object is [StringTest]
i is [10]
foo == bar ? False
bar == bar ? True

Annotation 29.
Parts of a Managed Module

Parts of a Managed Module

1. PE32 or PE32+header

2. CLR header

3. Metadata

4. IL code

metadata is a set of data tables that describe what is defined in the module, such as types and their members. In addition, metadata also has tables indicating what the managed module references, such as imported types and their members. an assembly is a logical grouping of one or more modules or resource files. Second, an assembly is the smallest unit of reuse, security, and versioning.

the C# compiler offers a /platform command-line switch. This switch allows you to specify whether the resulting assembly can run on x86 machines running 32-bit Windows versions only, x64 machines running 64-bit Windows only, or Intel Itanium machines running 64-bit Windows only. If you don’t specify a platform, the default is “anycpu”, which indicates that the resulting assembly can run on any version of Windows.

Annotation 30. The Access controlling options of a class member are as follows


A type that is visible to a caller can further restrict the ability of the caller to access the type’s members.

The following list shows the valid options for controlling access to a member:

1. Private The member is accessible only by other members in the same class type.

2. Family The member is accessible by derived types, regardless of whether they are within the same assembly. Note that many languages (such as C++ and C#) refer to family as protected.

3. Family and assembly The member is accessible by derived types, but only if the derived type is defined in the same assembly. Many languages (such as C# and Visual Basic) don’t offer this access control. Of course, IL Assembly language makes it available.

4. Assembly The member is accessible by any code in the same assembly. Many languages refer to assembly as internal.

5. Family or assembly The member is accessible by derived types in any assembly. The member is also accessible by any types in the same assembly. C# refers to family or assembly as protected internal.

6. Public The member is accessible by any code in any assembly.

Annotation 31. characteristics of System.Object

All types must (ultimately) inherit from a predefined type:

System.Object. As you can see, Object is the name of a type defined in the System namespace. This Object is the root of all other types and therefore guarantees that every type instance has a minimum set of behaviors. Specifically, the System.Object type allows you to do the following:

1. Compare two instances for equality.

2. Obtain a hash code for the instance.

3. Query the true type of an instance.

4. Perform a shallow (bitwise) copy of the instance.

5. Obtain a string representation of the instance object’s current state.

Annotation 32. the interoperability scenarios.

the CLR supports three interoperability scenarios:

1. Managed code can call an unmanaged function in a DLL Managed code can easily call functions contained in DLLs by using a mechanism called P/Invoke

2. Managed code can use an existing COM component (server), Using the type library from the already built components, a managed assembly can be created that describes the COM component. Managed code can access the type in the managed assembly just as any other managed type.

3. Unmanaged code can use a managed type (server) A lot of existing unmanaged code requires that you supply a COM component for the code to work correctly. It’s much easier to implement these components by using managed code so that you can avoid all of the code having to do with reference counting and interfaces.

Annotation 33. response files & its characteristics.

A response file is a text file that contains a set of compiler commandline switches. When you execute CSC.exe, the compiler opens response files and uses any switches that are specified in them as though the switches were passed to CSC.exe on the command line.

The metadata is a block of binary data that consists of several tables. There are three categories of tables: definition tables, reference tables, and manifest tables.

ModuleDef Always contains one entry that identifies the module. The entry includes the module’s file name and extension (without path) and a module version ID (in the form of a GUID created by the compiler). This allows the file to be renamed while keeping a record of its original name

TypeDef Contains one entry for each type defined in the module. Each entry includes the type’s name, base type, and flags (public, private, etc.) and contains indexes to the methods it owns in the MethodDef table, the fields it owns in the FieldDef table, the properties it owns in the PropertyDef table, and the events it owns in the EventDef table.

MethodDef Contains one entry for each method defined in the module. Each entry includes the method’s name, flags (private, public, virtual, abstract, static, final, etc.), signature, and offset within the module where its IL code can be found.

FieldDef Contains one entry for every field defined in the module. Each entry includes flags (private, public, etc.), type, and name.

ParamDef Contains one entry for each parameter defined in the module. Each entry includes flags (in, out, retval, etc.), type, and name.

PropertyDef Contains one entry for each property defined in the module. Each entry includes flags, type, and name.

EventDef Contains one entry for each event defined in the module. Each entry includes flags and name.

Annotation 34. characteristics of an assembly

An assembly is a collection of one or more files containing type definitions and resource files. One of the assembly’s files is chosen to hold a manifest. The manifest is another set of metadata tables that basically contain the names of the files that are part of the assembly. They also describe the assembly’s version, culture, publisher, publicly exported types, and all of the files that comprise the assembly.

Here are some characteristics of assemblies that you should remember:

a. An assembly defines the reusable types.

b. An assembly is marked with a version number.

c. An assembly can have security information associated with it.

An assembly’s individual files don’t have these attributes—except for the file that contains the manifest metadata tables. Assemblies deployed to the same directory as the application are called privately deployed assemblies

Annotation 35. types of assemblies

The CLR supports two kinds of assemblies: weakly named assemblies and strongly named assemblies.

An assembly can be deployed in two ways: privately or globally. A privately deployed assembly is an assembly that is deployed in the application’s base directory or one of its subdirectories. A weakly named assembly can be deployed only privately.

A globally deployed assembly is an assembly that is deployed into some well-known location that the CLR looks in when it’s searching for the assembly. A strongly named assembly can be deployed privately or globally.

A strongly named assembly consists of four attributes that uniquely identify the assembly: a file name (without an extension), a version number, a culture identity, and a public key.

If the referenced assembly isn’t in the GAC, the CLR looks in the application’s base directory and then in any of the private paths identified in the application’s configuration file; then, if the application was installed using MSI, the CLR asks MSI to locate the assembly. If the assembly can’t be found in any of these locations, the bind fails, and a System.IO.FileNotFoundException is thrown.

Any assembly that references .NET Framework assemblies always binds to the version that matches the CLR’s version. This is called unification, and Microsoft does this because they test all of the .NET Framework assemblies with a particular version of the CLR; therefore, unifying the code stack helps ensure that applications will work correctly.

To the CLR, all assemblies are identified by name, version, culture, and public key. However, the GAC identifies assemblies using name, version, culture, public key, and CPU architecture.

CLR uses the application’s XML configuration file to locate the moved files.

<?xml version=”1.0″?>

<configuration>

<runtime>

<assemblyBinding xmlns=”urn:schemas-microsoft-com:asm.v1″>

<probing privatePath=”AuxFiles;bin\subdir” />

<dependentAssembly>

<assemblyIdentity name=”JeffTypes” publicKeyToken=”32ab4ba45e0a69a1″

culture=”neutral”/>

<bindingRedirect oldVersion=”1.0.0.0″ newVersion=”2.0.0.0″ />

<codeBase version=”2.0.0.0″ href=”http://www.Wintellect.com/JeffTypes.dll” />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name=”TypeLib” publicKeyToken=”1f2e74e897abbcfe”

culture=”neutral”/>

<bindingRedirect oldVersion=”3.0.0.0-3.5.0.0″ newVersion=”4.0.0.0″ />

<publisherPolicy apply=”no” />

</dependentAssembly>

</assemblyBinding>

</runtime>

</configuration>

Annotation 36. the config file of assembly.

The XML config file contains

-probing element : Look in the application base directory’s AuxFiles and bin\subdir subdirectories when trying to find a weakly named assembly.

-First dependentAssembly, assemblyIdentity, and bindingRedirect elements : When attempting to locate version 1.0.0.0 of the culture-neutral JeffTypes assembly published by the organization that controls the 32ab4ba45e0a69a1 public key token, locate version 2.0.0.0 of the same assembly instead.

-codeBase element : When attempting to locate version 2.0.0.0 of the culture-neutral JeffTypes assembly published by the organization that controls the 32ab4ba45e0a69a1 public key token, try to find it at the following URL: www.Wintellect.com/JeffTypes.dll.

-Second dependentAssembly, assemblyIdentity, and bindingRedirect elements : When attempting to locate version 3.0.0.0 through version 3.5.0.0 inclusive of the culture-neutral TypeLib assembly published by the organization that controls the 1f2e74e897abbcfe public key token, locate version 4.0.0.0 of the same assembly instead.

-publisherPolicy element : If the organization that produces the TypeLib assembly has deployed a publisher policy file If the publisherPolicy element’s apply attribute is set to yes—or if the element is omitted—the CLR examines the GAC for the new assembly/version and applies any version number redirections that the publisher of the assembly feels is necessary; the CLR is now looking for this assembly/version.

you can’t specify the probing or publisherPolicy elements in a publisher policy configuration file.

Annotation 37. the publisher policy.

You create the publisher policy assembly by running AL.exe as follows: AL.exe /out:Policy.1.0.JeffTypes.dll /version:1.0.0.0 /keyfile:MyCompany.snk /linkresource:JeffTypes.config

Let me explain the meaning of AL.exe’s command-line switches:

/out This switch tells AL.exe to create a new PE file, called Policy.1.0.JeffTypes.dll, which contains nothing but a manifest. The name of this assembly is very important. The first part of the name, Policy, tells the CLR that this assembly contains publisher policy information. The second and third parts of the name, 1.0, tell the CLR that this publisher policy assembly is for any version of the JeffTypes assembly that has a major and minor version of 1.0. Publisher policies apply to the major and minor version numbers of an assembly only; you can’t create a publisher policy that is specific to individual builds or revisions of an assembly. The fourth part of the name, JeffTypes, indicates the name of the assembly that this publisher policy corresponds to. The fifth and last part of the name, dll, is simply the extension given to the resulting assembly file.

/version This switch identifies the version of the publisher policy assembly; this version number has nothing to do with the JeffTypes assembly itself. You see, publisher policy assemblies can also be versioned. Today, the publisher might create a publisher policy redirecting version 1.0.0.0 of JeffTypes to version 2.0.0.0. In the future, the publisher might want to direct version 1.0.0.0 of JeffTypes to version 2.5.0.0. The CLR uses this version number so that it knows to pick up the latest version of the publisher policy assembly.

/keyfile This switch causes AL.exe to sign the publisher policy assembly by using the publisher’s public/private key pair. This key pair must also match the key pair used for all versions of the JeffTypes assembly. After all, this is how the CLR knows that the same publisher created both the JeffTypes assembly and this publisher policy file.

/linkresource This switch tells AL.exe that the XML configuration file is to be considered a separate file of the assembly. The resulting assembly consists of two files, both of which must be packaged and deployed to the users along with the new version of the JeffTypes assembly.

By the way, you can’t use AL.exe’s /embedresource switch to embed the XML configuration file into the assembly file, making a single file assembly,because the CLR requires the XML file to be contained in its own separate file.

Annotation 38. publisher Policy element

A publisher should create a publisher policy assembly only when deploying an update or a service pack version of an assembly. When doing a fresh install of an application, no publisher policy assemblies should be installed.

the administrator would like to tell the CLR to ignore the publisher policy assembly. To have the runtime do this, the administrator can edit the application’s configuration file and add the following publisherPolicy element: <publisherPolicy apply=”no”/>

This element can be placed as a child element of the <assemblyBinding> element in the application’s configuration file so that it applies to all assemblies, or as a child element of the <dependantAssembly> element in the application’s configuration file to have it apply to a specific assembly.

In general, use a publisher policy assembly when you build a new version of your assembly that fixes a bug. You should test the new version of the assembly for backward compatibility. On the other hand, if you’re adding new features to your assembly, you should consider the assembly to have no relationship to a previous version, and you shouldn’t ship a publisher policy assembly. In addition, there’s no need to do any backward compatibility testing with such an assembly

Annotation 39. System.Object

the System.Object class offers the public instance methods namely

Public Method Description

Equals Returns true if two objects have the same value.

GetHashCode Returns a hash code for this object’s value. A type should override this method if its objects are to be used as a key in a hash table collection. The method should provide a

good distribution for its objects.

ToString Returns the full name of the type (this.GetType().FullName).However, it is common to override this method so that it returns a String object containing a representation of

the object’s state. For example, the core types,such as Boolean and Int32, override this method to return a string representation of their values. Note that ToString is

expected to be aware of the CultureInfo associated with the calling thread.
GetType Returns an instance of a Type-derived object that identifies the type of the object used to call GetType. The returned Type object can be used with the reflection classes to

obtain metadata information about the object’s type. The GetType method is nonvirtual, which prevents a class from overriding this method and lying about its type,

violating type safety.

Protected Method Description

MemberwiseClone This non-virtual method creates a new instance of the type and sets the new object’s instance fields to be identical to the this object’s instance fields. A reference to the new

instance is returned.

Finalize This virtual method is called when the garbage collector determines that the object is garbage before the memory for the object is reclaimed. Types that require cleanup

when collected should override this method.

Annotation 40. The CLR requires all objects to be created using the new operator.

Employee e = new Employee(“ConstructorParam1”);

Here’s what the new operator does:

1. It calculates the number of bytes required by all instance fields defined in the type and all of its base types up to and including System.Object (which defines no instance fields of its own). Every object on the heap requires some additional members—called the type object pointer and the sync block index—used by the CLR to manage the object. The bytes for these additional members are added to the size of the object.

2. It allocates memory for the object by allocating the number of bytes required for the specified type from the managed heap; all of these bytes are then set to zero (0).

3. It initializes the object’s type object pointer and sync block index members.

4. The type’s instance constructor is called, passing it any arguments (the string “ConstructorParam1” in the preceding example) specified in the call to new. Most compilers automatically emit code in a constructor to call a base class’s constructor. Each constructor is responsible for initializing the instance fields defined by the type whose constructor is being called. Eventually, System.Object’s constructor is called, and this constructor method does nothing but return. You can verify this by using ILDasm.exe to load MSCorLib.dll and examine System.Object’s constructor method.

Annotation 41. Is operator.

To cast in the C# language is to use the is operator. The is operator checks whether an object is compatible with a given type, and the result of the evaluation is a Boolean: true or false. The is operator will never throw an exception. The following code demonstrates:

Object o = new Object();

Boolean b1 = (o is Object); // b1 is true.

Boolean b2 = (o is Employee); // b2 is false.

If the object reference is null, the is operator always returns false because there is no object available to check its type.

The is operator is typically used as follows:

if (o is Employee) {

Employee e = (Employee) o;

// Use e within the remainder of the ‘if’ statement.

}

C# offers a way to simplify this code

and improve its performance by providing an as operator:

Employee e = o as Employee;

if (e != null) {

// Use e within the ‘if’ statement.

}

In this code, the CLR checks if o is compatible with the Employee type, and if it is, as returns a non-null reference to the same object. If o is not compatible with the Employee type, the as operator returns null.

The as operator works just as casting does except that the as operator will never throw an exception. Instead, if the object can’t be cast, the result is null.

Annotation 42. using directive

The C# using directive instructs the compiler to try prepending different prefixes to a type name until a match is found.

Namespace:

using Microsoft; // Try prepending “Microsoft.”

using Wintellect; // Try prepending “Wintellect.”

public sealed class Program {

public static void Main() {

Wintellect.Widget w = new Wintellect.Widget(); // Not ambiguous

}

}

Another way to remove the ambiguity, you must explicitly use alias to tell the compiler which Widget you want to create

using Microsoft; // Try prepending “Microsoft.”

using Wintellect; // Try prepending “Wintellect.”

// Define WintellectWidget symbol as an alias to Wintellect.Widget

using WintellectWidget = Wintellect.Widget;

public sealed class Program {

public static void Main() {

WintellectWidget w = new WintellectWidget(); // No error now

}

}

the C# compiler offers a feature called extern aliases that gives you a way to work around this rarely occurring problem. Extern aliases also give you a way to access a single type from two (or more) different versions of the same assembly.

Annotation 43. namespace

Creating a namespace is simply a matter of writing a namespace declaration into your code as follows (in C#):

namespace CompanyName {

public sealed class A { // TypeDef: CompanyName.A

}

namespace X {

public sealed class B { … } // TypeDef: CompanyName.X.B

}

}

The comment on the right of the class definitions above indicates the real name of the type the compiler will emit into the type definition metadata table; this is the real name of the type from the CLR’s perspective.

Creating a namespace is simply a matter of writing a namespace declaration into your code

as follows (in C#):

namespace CompanyName {

public sealed class A { // TypeDef: CompanyName.A

}

namespace X {

public sealed class B { … } // TypeDef: CompanyName.X.B

}

}

The comment on the right of the class definitions above indicates the real name of the type the compiler will emit into the type definition metadata table; this is the real name of the type from the CLR’s perspective.

In C#, the namespace directive simply tells the compiler to prefix each type name that appears in source code with the namespace name so that programmers can do less typing.

Any data types the compiler directly supports are called primitive types. Primitive types map directly to types existing in the Framework Class Library (FCL). For example, in C#, an int maps directly to the System.Int32 type.

Primitive Type    FCL Type    CLS-Compliant    Description
sbyte System.SByte No Signed 8-bit value
byte System.Byte Yes Unsigned 8-bit value
Short System.Int16 Yes Signed 16-bit value
ushort System.Uint16 No Unsigned 16-bit value
int System.Int32 Yes Signed 32-bit value
Uint System.Uint32 No Unsigned 32-bit value
long System.Int64 Yes Signed 64-bit value
ulong System.UInt64 No Unsigned 64-bit value
char System.Char Yes 16-bit Unicode character (char never represents an 8-bit value as it would inunmanaged C++.)
float System.Single Yes IEEE 32-bit floating point value
double System.Double Yes IEEE 64-bit floating point value
bool System.Boolean Yes A true/false value
decimal System.Decimal Yes A 128-bit high-precision floating-point value commonly used for financial calculations in which rounding errors can’t be tolerated. Of the 128 bits, 1 bit represents the sign of the value, 96 bits represent the value itself, and 8 bits represent the power of 10 to divide the 96-bit value by (can be
anywhere from 0 to 28). The remaining bits are unused.
string System.String    Yes    An array of characters
object System.Object Yes Base type of all types
Dynamic System.Object Yes To the common language runtime (CLR), dynamic is identical to object. However, the C# compiler allows dynamic variables to participate in dynamic dispatch using a simplified syntax.

Specifically, the C# compiler supports patterns related to casting, literals, and operators, as shown in the following examples :

First, the compiler is able to perform implicit or explicit casts between primitive types such as these:

Int32 i = 5; // Implicit cast from Int32 to Int32

Int64 l = i; // Implicit cast from Int32 to Int64

Single s = i; // Implicit cast from Int32 to Single

Byte b = (Byte) i; // Explicit cast from Int32 to Byte

Int16 v = (Int16) s; // Explicit cast from Single to Int16

Annotation 44. The /checked+ compiler switch

One way to get the C# compiler to control overflows is to use the /checked+ compiler switch. This switch tells the compiler to generate code that has the overflow-checking versions of the add, subtract, multiply, and conversion IL instructions. The code executes a little slower because the CLR is checking these operations to determine whether an overflow occurred. If an overflow occurs, the CLR throws an OverflowException.

Annotation 45. checked and unchecked operators


C# allows this flexibility by offering checked and unchecked operators. Here’s an example that uses the unchecked operator:

UInt32 invalid = unchecked((UInt32) (-1)); // OK

And here is an example that uses the checked operator:

Byte b = 100;

b = checked((Byte) (b + 200)); // OverflowException is thrown

b = (Byte) checked(b + 200); // b contains 44; no OverflowException

Annotation46. checked and unchecked statements

C# also offers checked and unchecked statements. The statements cause all expressions within a block to be checked or unchecked:

checked { // Start of checked block

Byte b = 100;

b = (Byte) (b + 200); // This expression is checked for overflow.

} // End of checked block

In fact, if you use a checked statement block, you can now use the += operator with the Byte, which simplifies the code a bit:

checked { // Start of checked block

Byte b = 100;

b += 200; // This expression is checked for overflow.

} // End of checked block

Annotation 47. system.valuetype

You need to bear in mind some performance considerations when you’re working with reference types.

The memory must be allocated from the managed heap.

Each object allocated on the heap has some additional overhead members associated with it that must be initialized.

The other bytes in the object (for the fields) are always set to zero.

Allocating an object from the managed heap could force a garbage collection to occur.

 Any type called a class is a reference type and each structure or an enumeration is a value type. All value types must be derived from System.ValueType. All enumerations are derived from the System.Enum

abstract type, which is itself derived from System.ValueType

In particular, you should declare a type as a value type if all the following statements are true:

The type acts as a primitive type. Specifically, this means that it is a fairly simple type that has no members that modify any of its instance fields. When a type offers no members that alter its fields, we say that the type is immutable. In fact, it is recommended that many value types mark all their fields as readonly

The type doesn’t need to inherit from any other type.

The type won’t have any other types derived from it.

So, in addition to the previous conditions, you should declare a type as a value type if one of the following statements is true:

Instances of the type are small (approximately 16 bytes or less).

Instances of the type are large (greater than 16 bytes) and are not passed as method parameters or returned from methods.

Annotation 48. differences between value type and reference type.

Here are some of the ways in which value types and reference types differ:

Value type objects have two representations: an unboxed form and a boxed form. Reference types are always in a boxed form.

Value types are derived from System.ValueType. This type offers the same methods as defined by System.Object. However, System.ValueType overrides the Equals method so that it returns true if the values of the two objects’ fields match. In addition, System.ValueType overrides the GetHashCode method to produce a hash code value by using an algorithm that takes into account the values in the object’s instance fields.

Because you can’t define a new value type or a new reference type by using a value type as a base class, you shouldn’t introduce any new virtual methods into a value type. No methods can be abstract, and all methods are implicitly sealed (can’t be overridden).

Reference type variables contain the memory address of objects in the heap. By default, when a reference type variable is created, it is initialized to null, indicating that the reference type variable doesn’t currently point to a valid object. Attempting to use a null reference type variable causes a NullReferenceException to be thrown. By contrast, value type variables always contain a value of the underlying type, and all members of the value type are initialized to 0. Since a value type variable isn’t a pointer, it’s not possible to generate a NullReferenceException when accessing a value type. The CLR does offer a special feature that adds the notion of nullability to a value type.

When you assign a value type variable to another value type variable, a field-by-field copy is made. When you assign a reference type variable to another reference type variable, only the memory address is copied.

Because of the previous point, two or more reference type variables can refer to a single object in the heap, allowing operations on one variable to affect the object referenced by the other variable. On the other hand, value type variables are distinct objects, and it’s not possible for operations on one value type variable to affect another.

Because unboxed value types aren’t allocated on the heap, the storage allocated for them is freed as soon as the method that defines an instance of the type is no longer active. This means that a value type instance doesn’t receive a notification (via a Finalize method) when its memory is reclaimed.

You tell the CLR what to do by applying the System.Runtime.InteropServices.StructLayoutAttribute attribute on the class or structure you’re defining. To this attribute’s constructor, you can pass LayoutKind.Auto to have the CLR arrange the fields, LayoutKind.Sequential to have the CLR preserve your field layout, or LayoutKind.Explicit to explicitly arrange the fields in memory by using offsets. If

you don’t explicitly specify the StructLayoutAttribute on a type that you’re defining, your compiler selects whatever layout it determines is best.

You should be aware that Microsoft’s C# compiler selects LayoutKind.Auto for reference types (classes) and LayoutKind.Sequential for value types (structures).

Here’s an example:

using System;

using System.Runtime.InteropServices;

// Let the CLR arrange the fields to improve

// performance for this value type.

[StructLayout(LayoutKind.Auto)]

internal struct SomeValType {

private readonly Byte m_b;

private readonly Int16 m_x;


}

using System;

using System.Runtime.InteropServices;

// The developer explicitly arranges the fields of this value type.

[StructLayout(LayoutKind.Explicit)]

internal struct SomeValType {

[FieldOffset(0)]

private readonly Byte m_b; // The m_b and m_x fields overlap each

[FieldOffset(0)]

private readonly Int16 m_x; // other in instances of this type

}

It should be noted that it is illegal to define a type in which a reference type and a value type overlap. It is possible to define a type in which multiple reference types overlap at the same starting offset; however, this is unverifiable. It is legal to define a type in which multiple value types overlap; however, all of the overlapping bytes must be accessible via public fields for the type to be verifiable.

It’s possible to convert a value type to a reference type by using a mechanism called boxing.

Internally, here’s what happens when an instance of a value type is boxed:

1. Memory is allocated from the managed heap. The amount of memory allocated is the size required by the value type’s fields plus the two additional overhead members (the type object pointer and the sync block index) required by all objects on the managed heap.

2. The value type’s fields are copied to the newly allocated heap memory.

3. The address of the object is returned. This address is now a reference to an object; the value type is now a reference type.

Note that the lifetime of the boxed value type extends beyond the lifetime of the unboxed value type.

The CLR accomplishes this copying in two steps. First, the address of the Point fields in the boxed Point object is obtained. This process is called unboxing. Then, the values of these fields are copied from the heap to the stack-based value type instance. Unboxing is not the exact opposite of boxing. The unboxing operation is much less costly than boxing. Unboxing is really just the operation of obtaining a pointer to the raw value type (data fields) contained within an object.

Internally, here’s exactly what happens when a boxed value type instance is unboxed:

1. If the variable containing the reference to the boxed value type instance is null, a NullReferenceException is thrown.

2. If the reference doesn’t refer to an object that is a boxed instance of the desired value type, an InvalidCastException is thrown.

The second item above means that the following code will not work as you might expect:

public static void Main() {

Int32 x = 5;

Object o = x; // Box x; o refers to the boxed object

Int16 y = (Int16) o; // Throws an InvalidCastException

}

Logically, it makes sense to take the boxed Int32 that o refers to and cast it to an Int16. However, when unboxing an object, the cast must be to the exact unboxed value type—Int32 in this case. Here’s the correct way to write this code:

public static void Main() {

Int32 x = 5;

Object o = x; // Box x; o refers to the boxed object

Int16 y = (Int16)(Int32) o; // Unbox to the correct type and cast

}

Passing a value type instance as an Object will cause boxing to occur, which will adversely affect performance. If you are defining your own class, you can define the methods in the class to be generic

// p1 DOES get boxed, and the reference is placed in c.

IComparable c = p1;

Console.WriteLine(c.GetType());// “Point”

When casting p1 to a variable (c) that is of an interface type, p1 must be boxed because interfaces are reference types by definition. So p1 is boxed, and the pointer to this boxed object is stored in the variable c. The following call to GetType proves that c does refer to a boxed Point on the heap.

When overriding the Equals method, there are a few more things that you’ll probably want to do:

Have the type implement the System.IEquatable<T> interface’s Equals method This generic interface allows you to define a type-safe Equals method

Overload the == and !=operator methods Usually, you’ll implement these operator methods to internally call the type-safe Equals method.

If you define a type and override the Equals method, you should also override the GetHashCode method. The reason why a type that defines Equals must also define GetHashCode is that the

implementation of the System.Collections.Hashtable type, the System.Collections. Generic.Dictionary type, and some other collections require that any two objects that are equal must have the same hash code value.

When your code invokes a member using a dynamic expression/variable, the compiler generates special IL code that describes the desired operation. This special code is referred to as the payload. At runtime, the payload code determines the exact operation to execute based on the actual type of the object now referenced by the dynamic expression/variable.

When the type of a field, method parameter, method return type, or local variable, is specified as dynamic, the compiler converts this type to the System.Object type and applies an

instance of System.Runtime.CompilerServices.DynamicAttribute to the field, parameter, or return type in metadata.

Note that the generic code that you are using has already been compiled and will consider the type to be Object; no dynamic dispatch will be performed because the compiler did not produce any payload code in the generic code.

Do not confuse dynamic and var. Declaring a local variable using var is just a syntactical shortcut that has the compiler infer the specific data type from an expression. The var keyword can be used only for declaring local variables inside a method while the dynamic keyword can be used for local variables, fields, and arguments. You cannot cast an expression to var but you can cast an expression to dynamic. You must explicitly initialize a variable declared using var while you do not have to initialize a variable declared with dynamic.

The C# compiler emits payload code that, at runtime, figures out what operation to perform based on the actual type of an object. This payload code uses a class known as a runtime binder.

At runtime, the C# runtime binder resolves a dynamic operation according to the runtime type of the object. The binder first checks to see if the type implements the IDynamicMetaObjectProvider interface. If the object does implement this interface, then the interface’s GetMetaObject method is called, which returns a DynamicMetaObjectderived type. This type can process all of the member, method, and operator bindings for the object. Both the IDynamicMetaObjectProvider interface and the DynamicMetaObject base class are defined in the System.Dynamic namespace, and both are in the System.Core.dll assembly.

When accessing a COM component, the C# runtime binder will use a DynamicMetaObject-derived type that knows how to communicate with a COM component. The COM DynamicMetaObject-derived type is defined in the System.Dynamic.dll assembly.

Annotation 49. .NET type and its members.

A type can define zero or more of the following kinds of members:

Constants: A constant is a symbol that identifies a never-changing data value.

Fields: A field represents a read-only or read/write data value. A field can be static, in which case the field is considered part of the type’s state. A field can also be instance (nonstatic), in which case it’s considered part of an object’s state.

Instance constructors: An instance constructor is a special method used to initialize a new object’s instance fields to a good initial state.

Type constructors: A type constructor is a special method used to initialize a type’s static fields to a good initial state.

Methods: A method is a function that performs operations that change or query the state of a type (static method) or an object (instance method). Methods typically read and write to the fields of the type or object.

Operator overloads : An operator overload is a method that defines how an object should be manipulated when certain operators are applied to the object. Because not all programming languages support operator overloading, operator overload methods are not part of the Common Language Specification (CLS).

Conversion operators: A conversion operator is a method that defines how to implicitly or explicitly cast or convert an object from one type to another type. A conversion operator are not part of CLS.

Properties: A property is a mechanism that allows a simple, field-like syntax for setting or querying part of the logical state of a type (static property) or object (instance property) while ensuring that the state doesn’t become corrupt.

Events: A static event is a mechanism that allows a type to send a notification to one or more static or instance methods. An instance (nonstatic) event is a mechanism that allows an object to send a notification to one or more static or instance methods.Events are usually raised in response to a state change occurring in the type or object offering the event. An event consists of two methods that allow static or instance methods to register and unregister interest in the event. In addition to the two methods, events typically use a delegate field to maintain the set of registered methods.

Types : A type can define other types nested within it. This approach is typically used to break a large, complex type down into smaller building blocks to simplify the implementation.

When the corresponding compiler must process your source code and produce metadata and Intermediate Language (IL) code for each kind of member in the preceding list. The format of the metadata is identical regardless of the source programming language you use, and this feature is what makes the CLR a common language runtime. The metadata is the key to the whole Microsoft .NET framework development platform; it enables the seamless integration of languages, types, and objects.

Annotation50. Member accessiblity

A public type is visible to all code within the defining assembly as well as all code written in other assemblies.

An internal type is visible to all code within the defining assembly, and the type is not visible to code written in other assemblies.

The C# compiler requires you to use the /out:<file> compiler switch when compiling the friend assembly (the assembly that does not contain the InternalsVisibleTo attribute). The switch is required

because the compiler needs to know the name of the assembly being compiled in order to determine if the resulting assembly should be considered a friend assembly.

Also, if you are compiling a module (as opposed to an assembly) using C#’s /t:module switch, and this module is going to become part of a friend assembly, you need to compile the module by using the C# compiler’s /moduleassemblyname:<string> switch as well. This tells the compiler what assembly the module will be a part of so the compiler can allow code in the module to access the other assembly’s internal types.

Table 6-1 Member Accessibility

CLR Term C# Term Description
Private private The member is accessible only by methods in the defining type or any nested type.
Family Protected The member is accessible only by methods in the defining type, any nested type, or one of its derived types without regard to assembly.
Family and Assembly (not supported) The member is accessible only by methods in the defining type, any nested type, or by any derived types defined in the same assembly.
Assembly internal The member is accessible only by methods in the defining assembly.
Family or Assembly protected internal The member is accessible by any nested type, any derived type (regardless of assembly), or any methods in the defining assembly.
Public Public The member is accessible to all methods in any assembly.

The compiler enforces many restrictions on a static class:

The class must be derived directly from System.Object because deriving from any other base class makes no sense since inheritance applies only to objects, and you cannot create an instance of a static class.

The class must not implement any interfaces since interface methods are callable only when using an instance of a class.

The class must define only static members (fields, methods, properties, and events). Any instance members cause the compiler to generate an error.

The class cannot be used as a field, method parameter, or local variable because all of these would indicate a variable that refers to an instance, and this is not allowed. If the compiler detects any of these uses, the compiler issues an error.

E.g.

using System;

public static class AStaticClass

{

public static void AStaticMethod() { }

public static String AStaticProperty

{

get { return s_AStaticField; }

set { s_AStaticField = value; }

}

private static String s_AStaticField;

public static event EventHandler AStaticEvent;

}

Annotation 51.Partial keyword

The partial keyword tells the C# compiler that the source code for a single class, structure, or interface definition may span one or more source code files.

Using the partial keyword allows you to split the code for the type across multiple source code files, each of which can be checked out individually so that multiple programmers can edit the type at the same time.

Splitting a class or structure into distinct logical units within a single file

Code spitters : Visual Studio creates two source code files: one for your code and the other for the code generated by the designer.

Annotation 52. Explain the namespaces in which .NET has the data functionality class.

System.data contains basic objects. These objects are used for accessing and storing relational data. Each of these is independent of the type of data source and the way we connect to it.

These objects are:
1.DataSet
2.DataTable
3.DataRelation.

System.Data.OleDB objects are used to connect to a data source via an OLE-DB provider.These objects have the same properties, methods, and events as the SqlClient equivalents.A few of the object providers are:

1.OleDbConnection
2.OleDbCommand

System.Data.SqlClient objects are used to connect to a data source via the Tabular Data Stream (TDS) interface of only Microsoft SQL Server.The intermediate layers required by an OLE-DB connection are removed in this.This provides better performance.System.XML contains the basic objects required to create, read, store, write, and manipulate XML documents according to W3C recommendations.

Annotation 53. Overview of ADO.NET architecture.

Data Provider provides objects through which functionalities like opening and closing connection, retrieving and updating data can be availed.It also provides access to data source like SQL Server, Access, and Oracle).Some of the data provider objects are:

1.Command object which is used to store procedures.
2.Data Adapter which is a bridge between datastore and dataset.
3.Datareader which reads data from data store in forward only mode.

Annotation 54. a dataset object.

A dataset object is not in directly connected to any data store. It represents disconnected and cached data. The dataset communicates with Data adapter that fills up the dataset. Dataset can have one or more Datatable and relations.DataView object is used to sort and filter data in Datatable.

Annotation 55. the ADO.NET architecture.

ADO.NET provides access to all kind of data sources such as Microsoft SQL Server, OLEDB, Oracle, XML.ADO.NET separates out the data access and data manipulation componenets. ADO.NET includes some providers from the .NET Framework to connect to the database, to execute commands, and finally to retrieve results. Those results are either directly used or can be put in dataset and manipulate it.

Annotation 56. the steps to perform transactions in .NET

Following are the general steps that are followed during a transaction:
1.Call the BeginTransaction. This marks the beginning of the transaction.
2.Assign the Transaction object returned by BeginTransaction to the Transaction property of the SqlCommand.
3.Execute the command.
4.Call the Commit method from SqlTransaction object to save the changes made to the data through the transaction. Call Rollback undo all the transaction which belong to this transaction.

Annotation 57. Define connection pooling

A connection pool is created when a connection is opened the first time. The next time a connection is opened, the connection string is matched and if found exactly equal, the connection pooling would work.Otherwise, a new connection is opened, and connection pooling won’t be used.Maximum pool size is the maximum number of connection objects to be pooled.If the maximum pool size is reached, then the requests are queued until some connections are released back to the pool. It is therefore advisable to close the connection once done with it.

Connection pooling is a method of reusing the active database connections instead of creating new ones every time the user request one. Connection pool manager keeps track of all the open connections. When a new request comes in, the pool manager checks if there exists any unused connections and returns one if available. If all connections are busy and the maximum pool size has not been reached, a new connection is formed and added to the pool. And if the max pool size is reached, then the requests gets queued up until a connection in the pool becomes available or the connection attempt times out.

Connection pooling behavior is controlled by the connection string parameters. The following are four parameters that control most of the connection pooling behavior:Default max pool size is 100.

Annotation 58. Steps to enable and disable connection pooling?

Set Pooling=true. However, it is enabled by default in .NET.To disable connection pooling set Pooling=false in connection string if it is an ADO.NET Connection.If it is an OLEDBConnection object set OLEDB Services=-4 in the connection string.

Annotation 59. explain enabling and disabling connection pooling.

To enable connection pooling:

SqlConnection myConnection = new SqlConnection(@”Data Source=(local)\SQLEXPRESS; Initial Catalog = TEST;Integrated Security=SSPI;”);
This has connection pooling on by default

To disable connection pooling:
SqlConnection myConnection = new SqlConnection(@”Data Source=(local)\SQLEXPRESS;Initial Catalog=TEST;Integrated Security=SSPI;Pooling=false;”);

Annotation 60. What is the relation between Classes and instances?

Class is a group of items, attributes of some entity. Object is any specific item that may or may not be a part of the class. When a class is created, objects for those classes are created.Example:-We create a Class “Food”. This class has attributes like ‘price’, ‘quantity’. For this food class, we create objects like “Spaghetti”, “Pasta”.

Annotation 61.Difference between dataset and datareader.


Dataset is

1.Disconnected
2.Can traverse data in any order front, back.
3.Data can be manipulated within the dataset.
4.More expensive than datareader as it stores multiple rows at the same time.

Datareader is

1.Connection needs to be maintained all the time
2.Can traverse only forward.
3.It is read only therefore, data cannot be manipulated.
4.It is less costly because it stores one row at a time

Annotation 62. What are command objects?

The command objects are used to connect to the Datareader or dataset objects with the help of the following methods:

1.ExecuteNonQuery:

This method executes the command defined in the CommandText property.The connection used is defined in the Connection property for a query.It returns an Integer indicating the number of rows affected by the query.

2.ExecuteReader:

This method executes the command defined in the CommandText property.The connection used is defined in the Connection property.It returns a reader object that is connected to the resulting rowset within the database, allowing the rows to be retrieved.

3.ExecuteScalar:

1.This method executes the command defined in the CommandText property.
2.The connection used is defined in the Connection property.
3.It returns a single value which is the first column of the first row of the resulting rowset.
4.The rows of the rest of the result are discarded.
5.It is fast and efficient in cases where a singleton value is required.

Command objects are used to execute the queries, procedures. Sql statements etc. It can execute stored procedures or queries that use parameters as well.
It works on the basis of certain properties like ActiveConnection, CommandText, CommandType, Name etc.Command object has three methods:

1.Execute: executes the queries, stored procedures etc.
2.Cancel: stops the method execution
3.CreateParameter: to create a parameter object

Annotation63. the use of data adapter.

The data adapter objects connect a command objects to a Dataset object.They provide the means for the exchange of data between the data store and the tables in the DataSet.An OleDbDataAdapter object is used with an OLE-DB provider.A SqlDataAdapter object uses Tabular Data Services with MS SQL Server.
Data adapters are the medium of communication between datasource like database and dataset. It allows activities like reading data, updating data.

Annotation 64. The basic methods of Dataadapter

The most commonly used methods of the DataAdapter are:

1.Fill:
This method executes the SelectCommand to fill the DataSet object with data from the data source.Depending on whether there is a primary key in the DataSet, the ‘fill’ can also be used to update an existing table in a DataSet with changes made to the data in the original datasource.

2.FillSchema
This method executes the SelectCommand to extract the schema of a table from the data source.It creates an empty table in the DataSet object with all the corresponding constraints.

3.Update
This method executes the InsertCommand, UpdateCommand, or DeleteCommand to update the original data source with the changes made to the content of the DataSet.

Annotation 65. the steps involved to fill a dataset.

The DataSet object is a disconnected storage.It is used for manipulation of relational data.
The DataSet is filled with data from the store.We fill it with data fetched from the data store. Once the work is done with the dataset, connection is reestablished and the changes are reflected back into the store.

Steps to fill a dataset in ADO.NET are:
1.Create a connection object.
2.Create an adapter by passing the string query and the connection object as parameters.
3.Create a new object of dataset.
4.Call the Fill method of the adapter and pass the dataset object.

Annotation 66. Identifying changes made to dataset since it was loaded.

The changes made to the dataset can be tracked using the GetChanges and HasChanges methods.The GetChanges returns dataset which are changed since it was loaded or since Acceptchanges was executed.The HasChanges property indicates if any changes were made to the dataset since it was loaded or if acceptchanges method was executed.The RejectChanges can be used to revert thee changes made to the dataset since it was loaded.

Annotation 67. Steps to add/remove row’s in “DataTable” object of “DataSet”

‘NewRow’ method is provided by the ‘Datatable’ to add new row to it.’DataTable’ has “DataRowCollection” object which has all rows in a “DataTable” object.
Add method of the DataRowCollection is used to add a new row in DataTable.We fill it with data fetched from the data store. Once the work is done with the dataset, connection is reestablished.Remove method of the DataRowCollection is used to remove a ‘DataRow’ object from ‘DataTable’.RemoveAt method of the DataRowCollection is used to remove a ‘DataRow’ object from ‘DataTable’ per the index specified in the DataTable.

Annotation 68. the basic use of “DataView” and its methods.

A DataView is a representation of a full table or a small section of rows.It is used to sort and find data within Datatable.Following are the methods of a DataView:
1.Find : Parameter: An array of values; Value Returned: Index of the row
2.FindRow : Parameter: An array of values; Value Returned: Collection of DataRow
3.AddNew : Adds a new row to the DataView object.
4.Delete : Deletes the specified row from DataView object

Annotation 69. To load multiple tables in a DataSet.

MyDataSet myds = new MyDataSet();

SqlDataAdapter myda = new SqlDataAdapter (“procId”, this.Connection);
myda.SelectCommand.CommandType = CommandType.StoredProcedure;
myda.SelectCommand.Parameters.AddWithValue (“@pId”, pId);
myda.TableMappings.Add (“Table”, myds.xval.TableName);
myda.Fill (myds);

ADO.NET Code showing Dataset storing multiple tables.
DataSet ds = new DataSet();
ds.Tables.Add(dt1);
ds.Tables.Add(dt2);
ds.Tables.Add(dtn);

Annotation 70. applications of CommandBuilder

CommandBuilder builds “Parameter” objects automatically.CommandBuilder is used to build complex queries. It can even build commands that are based on the returned results. CommandBuilder is less error prone and more readable than the command object.

Annotation 71. Define connected and disconnected data access in ADO.NET

Data reader is based on the connected architecture for data access. Does not allow data manipulation.Dataset supports disconnected data access architecture. This gives better performance results.

Annotation 72. Describe CommandType property of a SQLCommand in ADO.NET.

CommandType is a property of Command object which can be set to Text, Storedprocedure. If it is Text, the command executes the database query. When it is StoredProcedure, the command runs the stored procedure. A SqlCommand is an object that allows specifying what is to be performed in the database.

Access database at runtime using ADO.NET
SqlConnection sqlCon = new SqlConnection(connectionString)
sqlCon.Open();
string strQuery = “select CategoryName from abcd”;
SqlCommand cmd = new SqlCommand(strQuery, conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader [0]);
}
reader.Close();
con.Close();

Annotation 73. list the debugging windows available.     

The windows which are available while debugging are:
Breakpoints, Output, Watch, Autos, Local, Immediate, Call Stacks, Threads, Modules, Processes, Memory, Disassembly and Registers.

Annotation 74. Break mode:

When changes are made to the code in an application, the way to be able to view how those changes have changed the way of execution is Break Mode. In break mode, a snapshot of the running application is taken in which the status and values of all the variables is stored.

Annotation 75. the options for stepping through code

The applications consist of various activities which need to be performed during the execution. Some of them are composite activities which need to be executed in parallel or conditionally. These activities are classified as ParallelActiviy and ConditionalActivity.

The two options of debugging handle these activities differently as follows:

1. Branch stepping:
In this, when the control gets transferred to another concurrent activity, it happens without being noticed. Only the activities in the currently selected branch are stepped through although other activities in the workflow may be executing concurrently. If you want to debug any concurrent activity, then a breakpoint needs to be placed appropriately. Stepping continues in that branch when the breakpoint is triggered.

2. Instance stepping:
In this, you can step through as well as debug the concurrent activities. You can even notice the change in control that occurs when concurrently executing activities get executed. Instance stepping option should be chosen while debugging state machine workflows.

Annotation 76. define a Breakpoint

Using Breakpoints you can break or pause the execution of an application at a certain point.
A breakpoint with an action associated with it is called a ‘tracepoint’. Using tracepoints, the debugger can perform additional actions instead of having an application only enter a break mode.

Annotation 77. Define Debug and Trace Class.

1.Debug Class (System.Diagnostics)
It provides a set of methods and properties that help debug your code. This class cannot be inherited.

2.Trace Class (System.Diagnostics)
It provides a set of methods and properties that help you trace the execution of your code. This class cannot be inherited. For a list of all members of this type, see Trace Members.

Annotation 78. What are Trace switches?

Trace switches are used to enable, disable and filter the tracing output. They are objects can be configured through the .config file.

Annotation 79. configuration of trace switches in the application’s .config file.

Switches are configured using the .config file.Trace switches can be configured in an application and the trace output can be enabled or disabled. Configuring involves changing the value of the switch from an external source after being initialized.The values of the switch objects can be changed using the .config file.

Annotation 80. What is an Event?

When an action is performed, this action is noticed by the computer application based on which the output is displayed. These actions are called events. Examples of events are pressing of the keys on the keyboard, clicking of the mouse. Likewise, there are a number of events which capture your actions.

Annotation 81. Define Delegate.     

Delegates are kind of similar to the function pointers. But they are secure and type-safe.A delegate instance encapsulates a static or an instance method.
Declaring a delegate defines a reference type which can be used to encapsulate a method having a specific signature.

Annotation 82. What is the purpose of AddHandler keyword?

The AddHandler statement allows you to specify an event handler. AddHandler has to be used to handle shared events or events from a structure.
The arguments passed to the Addhandler are:
1.The name of an event from an event sender and
2.An expression that evaluates to a delegate

Annotation 83. exceptions handling in CLR

Usually the exceptions that occur in the try are caught in the catch block. The finally is used to do all the cleaning up work. But exceptions can occur even in the finally block. By using CLR, the exception are caught even in the finally block. Also when an exception is thrown, the CLR looks for an appropriate catch filter that can handle the exception and then it executes the finally block before terminating the execution on the catch filter.

The code in the finally always runs. If you return out of the try block, or even if you do a “goto” out of the try, the finally block always runs:

using System;

class main
{
public static void Main()
{
try
{
Console.WriteLine(“In Try block”);
return;
}
finally
{
Console.WriteLine(“In Finally block”);
}
}
}

Both “In Try block” and “In Finally block” will be displayed. Whether the return is in the try block or after the try-finally block, performance is not affected either way. The compiler treats it as if the return were outside the try block anyway. If it’s a return without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has an expression, there’s an extra store/load of the value of the expression (since it has to be computed within the try block).

Annotation 84. create and throw a custom exception.     

The usual try – catch – finally – ent try format has to be followed. However, in this case, instead of using the preset exceptions from the System.Exception, you define your OwnException class and inherit Exception or ApplicationException class.You need to define three constructors in your OwnException Class: One without parameters, other with String parameter for error message and the last one has to have one parameter as a String and other as an Inner exception object.

Example:
class OwnException : ApplicationException
{
public OwnException() : base() {}
public OwnException(string s) : base(s) {}
public OwnException(string s, Exception ae) : base(s, ae) {}
}

Annotation 85. difference between Localization and Globalization

In Globalization, an application is developed to support various languages and cultures.Its features and code design independent of a single language or locale.In Localization, an application is adapted for a local market. It may include translation of the UI to the local language and customizing its features if necessary.

Annotation 86. Define Unicode

Unicode is a 16-bit character encoding scheme that enables characters from various languages to be used. The characters are taken from languages of Western European, Eastern European, Cyrillic, Greek, Arabic, Hebrew, Chinese, Japanese, etc regions. It is defined by ISO 10646.

Annotation 87. Steps to generate a resource file

Resource files are used to separate the implementation of the application from its User Interface. Thus, it eliminates the need to change a various sections of code to add a different language.

Annotation 88. Implementation of globalization and localization in the use interface in .NET.

Globalization is the process of making an application that supports multiple cultures without mixing up the business logic and the culture related information of that application. Localization involves adapting a global application and applying culture specific alterations to it. The classes and the interfaces provided by the System.Resources allow storing culture specific resources.

Annotation 89. the functions of the Resource Manager class

The ResourceManager class performs:

1.A look up for culture-specific resources
2.Provision of resource fallback when a localized resource does not exist
3.Supports for resource serialization

Annotation 90. Explain preparation of culture-specific formatting in .NET.

The CutureInfo class can be used for this purpose. It represents information about a specific culture including the culture names, the writing system, and the calendar. It also provides an access to objects that provide information for common operations like date formatting and string sorting.

Annotation 91. Define XCopy

XCopy command is an advanced version of the copy command used to copy or move the files or directories to another location (including locations across networks). It excludes the hidden and system files.

Annotation 92. Explain visual INHERITANCE OF windows forms.

Steps:
1.Create a windows form called the base window
2.Add a menu bar on this form
3.Right click on the solution explorer and select add new item
4.Select inherited form
5.From the dialogue box choose basewindow form.
6.Name the new form as the childform
7.Now the new childform would have a menu from the baseform.
8.We can place as many controls on baseform as we want to.

Annotation 93. Explain the lifecycle of the form.

1.Load: fired when form is first loaded in the application
2.Activated: fired whenever the form gets the focus i.e. when loaded first time, restored from the minimize state, whenever the form is brought in front.
3.Deactivated: fired whenever the form looses focus i.e. when form is closed, minimized, when it is in background.
4.Closing: Triggered when application wishes to be closed.
5.Closed: Triggered when application is closed.
6.Disposed: Used for garbage collection.

Annotation 94. Explain the steps to create menus 

1.MenuItem item1=new MenuItem();
2.item1.text=”item1″;
3.item1.Value=”one”;
4.Menu1.items.add(item1);

Annotation 95. Anchoring a control and Docking a control

1. Anchoring: used to resize controls dynamically with the form.
2. Docking: to adhere to the edges of its container.

Annotation 96. Define ErrorProvider control.

It is a control to provide a feedback about another control that has an error. It allows user to see where the error is by displaying a blinking icon in front of the control. On mousehover, tooltip appears showing the control description.

Annotation 97. Explain building a composite control 

Steps to create a Composite control:

1.Select a project
2.Right click and add a new item (User Control – .ascx) to the selected project.
3.Add @Control Directive
4.Add all the controls that you want to be displayed on the User control as a part of one or more web pages.
5.Write the code for all the tasks to be performed by the user control.
6. Create accessor methods for the outside world accessing this user control.

Annotation 98. Explain the ways to deploy your windows application ?

The ways to deploy your windows application
1.Merge Module Project: Allows the package of the components to be shared between multiple applications.
2.Setup Project: Builds an msi and exe installer for a Windows application.
3.Web Setup Project: Builds an installer for a Web application.
4.Cab Project: Creates a cabinet file for downloading.

Annotation 99. Explain 3 types of configuration files in windows application in .NET?

1.Application Coniguration: They contain configuration settings specific to applications. These files provide a way of overriding the metadata in assemblies without having to rebuild the application.

2.Machine Configuration Files:Machine Configuration allows to provide settings for all the applications on a computer. The name of machine configuration file is machine.config.

3.Security configuration files: It contains information that describes the permissions and rights. The information in this files can be related to code access security system.

Annotation 100. What are the ways to optimize the performance of a windows application?

1.Knowing when to use StringBuilder
2.Comparing Non-Case-Sensitive Strings
3.Use string.Empty
4.Replace ArrayList with List
5.Use && and || operators
6.Smart Try-Catch
7.Replace Divisions
8.Code profiling
9.Use performance monitor to observe counters written in the application

Annotation 101. List out difference between the Debug class and Trace class.  

Use debug class for debug builds, use Trace class for both debug and release builds.

Annotation 102. Name three test cases you should use in unit testing? 

Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).

Annotation 103. Explain the finally statement in C#.NET.

Finally statement is executed always irrespective of any condition or error occurring in a method. It is often used to cleanup code.
E.g.:

public void MyMethod()
{
try
{
//code to connect to database
//code to perform action
}
catch (Exception ex)
{
//handle exception
}
finally
{
//code to disconnect database.
}
}

Annotation 104. the steps to create and implement Satellite Assemblies.

Satellite assemblies are resource assemblies specific to language/culture. Different resource files are created for different languages/cultures and then the needed one is loaded based on the user.

1. Create a new web application
2. Drag 2 label controls, a dropdownlist and a button control. Add 2 items to the drop down, en-US and fr-FR.
3. Add a new folder called resources and add 2 resource assembly files in it., e.g.: res1.resx and res1.fr-FR.resx In res1.resx, add a key “Welcome” and value as “Hello there”. In res1.fr-FR.resx, add a key called “Welcome” and value as “Bon Journe”.
4. Generate their resource files by using the resgen command for each of these resource files and keep them in the App_GlobalResources folder.
5. On button’s click even at the following code:
6. Session[“language”]=dropdownlist1.SelectedItem .Text ;
Response.Redirect (“Webform2.aspx”);
7. Add a label inWebform2.aspx.
When you execute the Webform1.aspx, choose one of the English or French option from the dropdownlist and hit the button. It should display welcome message based on the chosen option from the dropdownlist.

Annotation 105. Explain the purpose of ResourceManager class. name the namespace that contains it.

Use ResourceManager class to retrieve resources that exist in an assembly. Steps to do so are:

1.create a reference to the assembly that has the resources.
2.create an instance of ResourceManager.
3.specify the base name of the resource file and provide the reference to the assembly that contains it.
4.Use the ResouceManager’s GetObject or GetString method to retrive the resource.
System.Resources namespace contains it.

Annotation 106. Explain the purpose of CultureInfo class. What namespace contains it?

System.Globalization namespace contains CultureInfo class. This class provides information about a specific culture, i.e. datetime format, currency, language etc.

Annotation 107. Explain steps to prepare culture-specific formatting.

The NumberFormatInfo class is used to define how symbols, currencies etc are formatted based on specific cultures.
E.g.:

using System;
using System.Globalization;

public class TestClass
{
public static void Main()
{
int i = 100;
// Creates a CultureInfo for English in the U.S.
CultureInfo us = new CultureInfo(“en-US”);
// Display i formatted as currency for us.
Console.WriteLine(i.ToString(“c”, us));

             // Creates a CultureInfo for French.
CultureInfo fr = new CultureInfo(“fr-FR”);
// Displays i formatted as currency for france.
Console.WriteLine(i.ToString(“c”, fr));
}
}

Annotation 108. the Steps to implement localizability to the user interface?

Steps to implement localizability to the user interface.Implementation consists of basically translating the UI.set the culture and UI culture for an application make the following entry in the web.config

 For setting culture in pages use the following:

Annotation 109. Define Trace Listeners and Trace Switches?

Trace listeners are objects that are used to receive store and route tracing information. The trace listener decides the final destination where the tracing information is routed to. There are 3 types
Default, TextWriter and EventLog
Trace switches are used to define behavior of Trace Listeners.

E.g.:

both switches are off, to turn them on , replace 0 by 1.

Annotation 110. Explain tracing with an example using C#.NET.

In web.config, set EnableTracing=”true”

System.Diagnostics.Trace.WriteLine (“Error in Method1.”);
System.Diagnostics.Trace.WriteLineIf(variable, “Error in Method1.”);

Annotation 111. Define CLR triggers.

A CLR trigger could be a Date Definition or Date Manipulation Language trigger or could be an AFTER or INSTEAD OF trigger.Methods written in managed codes that are members of an assembly need to be executed provided the assembly is deployed in SQL 2005 using the CREATE assembly statement.The Microsoft.SqlServer.Server Namespace contains the required classes and enumerations for this objective.

Steps for creating CLR Trigger

Follow these steps to create a CLR trigger of DML (after) type to perform an insert action:
1. Create a .NET class of triggering action
2. Make an assembly (.DLL) from that Class
3. Enable CLR environment in that database.
4. Register the assembly in SQL Server
5. Create CLR Trigger using that assembly

Annotation 112. Difference between an interface and abstract class 

In the interface all methods must be abstract; In the abstract class some methods can be concrete.
In the interface no accessibility modifiers are allowed, which is possible in abstract classes.

Annotation 113. Difference between System.String and System.StringBuilder classes. 

System.String is immutable;System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations  can be performed.

Annotation 114. List different ways to deploy an assembly. 

MSI installer, a CAB archive, and XCOPY command.

Annotation 115. Define Satellite Assembly. 

When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

Annotation 116. Declare a custom attribute for the entire assembly.

Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows:
using System;
[assembly : MyAttributeClass] class X {}
Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.

Annotation 117. Explain abstraction in C#.NET.

Abstraction is used to create a common set of methods that might have different specific implementations by subclasses. Abstract class cannot be instantiated and consists of abstract methods without any implementations. Classes inheriting from abstract class must implement all the methods in abstract class.

Public abstract class Shape
{
Private float _area;
Public Float Area
{
Get{return _area;}
Set{_area=value;}
}
Public abstract void CalculateArea();

     Class Rect:Shape
     {
           Private float _height;
           Private float _width;
           Public Rect(float height, float width)
           {
                   _height = height;
                   _width = width;
           }
           Public Float Height
           {
                 Get{return _height}
                 Set{_height=value;}
           }
           Public Float Width
           {
                  Get{return _width}
                  Set{_width=value;}
           }
           Public override void CalculateArea()
           {
                  This.Area=_height*_width;
      }
}

Annotation 118. Explain encapsulation usage in C#.

Encapsulation hides the internal state and behavior of an object. Encapsulation if used with access modifiers such as private, public, protected. It provides a way to protect data.

public class MyClass
{
private string name;
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
}
public class main
{
public static int Main(string[] args)
{
MyClass myclass = new MyClass();
myclass.name = “Communication”;
Console.WriteLine(“The name is :{0}”, myclass.Name);
return 0;
}
}

See use of encapsulation through properties for accessing and setting the values.

Annotation 119. Differentiate between instance data and class data

Class data in terms of static class is the data that particular class holds in its structure. Instances can refer to different objects of the same class that hold different values using the same class structure in memory heap.

Annotation 120. the significance of static method

Static methods are used when we want only one copy of that method to perform action and remain active at a single point in time.Imagine a scenario where you need a class to connect to the database once and remain as it is for the entire application.

public static class MyDbConnection
{
public static void ConnectToDb()
{
//code to connect to database
}
}
public void SomeMethod()
{
MyDbConnection.ConnectToDb();
}
You don’t want different instances of this class to be created and connect to the database again and again, hence make a static method in a static class.

Annotation 121. The application of boxing and unboxing.

Boxing and Unboxing are used to convert value types into reference types and vice versa. Developers often need to make some methods generic and hence create methods that accept objects rather than specific value types. The advantage of reference types is that they don’t create a copy of the object in memory, instead pass the reference of the data in the memory. This uses memory much more efficiently, especially, if the object to be passed is very heavy.

public class MyClass
{
public void MyClass()
{
}
public void MyMethod()
{
int intVar1 = 1; // i is an integer. It is a value type variable.
object objectVar = intVar1;
// boxing occurs. The integer type is parsed to object type
int intVar2 = (int)objectVar;
// unboxing. The object type is unboxed to the value type
}
}

Annotation 122. Explain calling a native function exported from a DLL?

Here’s a quick example of the DllImport attribute in action:
using System.Runtime.InteropServices; \
class C
{
[DllImport(“user32.dll”)]
public static extern int MessageBoxA(int h, string m, string c, int type);
public static int Main()
{
return MessageBoxA(0, “Hello World!”, “Caption”, 0);
}
}
This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA. For more information, look at the Platform Invoke tutorial in the documentation.

Annotation 123. Simulation of optional parameters to COM functions.

You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.

Annotation 124. Sealed class in C#.NET

The sealed modifier is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class. A sealed class cannot also be an abstract class.

Annotation 125. generics in C#.NET

Generic types to maximize code reuse, type safety, and performance. They can be used to create collection classes. Generic collection classes in the System.Collections.Generic namespace should be used instead of classes such as ArrayList in the System.Collections namespace.

The classes and the methods can treat the values of different types uniformly with the use if generics. The usage of generics is advantageous as:
1.They facilitate type safety
2.They facilitate improved performance
3.They facilitate reduced code
4.They promote the usage of parameterized types
5.The CLR compiles and stores information related to the generic types when they are instantiated. (The generic type instance refers to the location in memory of the reference type to which it is bound for all the instances of the generic type.)

Annotation 126. marking a method obsolete

[Obsolete] public int Foo() {…}or

[Obsolete(“This is a message describing why this method is obsolete”)] public int Foo() {…}Note: The O in Obsolete is always capitalized.

Annotation 127. System.Environment class in C#.NET.

The System.Environment class can be used to retrieve information like:
1.command-line arguments
2.the exit code
3.environment variable settings
4.contents of the call stack
5.time since last system boot
6.the version of the common language runtime.

Annotation 128. implementation of synchronization in C#.

You want the lock statement, which is the same as Monitor Enter/Exit:
lock(obj) { // code }
translates to

try {
CriticalSection.Enter(obj);
// code
}
finally
{
CriticalSection.Exit(obj);
}

Annotation 129. the advantages of CLR procedure over T-SQL procedure.

The use of the CLR procedure makes it possible to do the complex database operations without having an in-depth knowledge of T-SQL. It also enables focusing the business layer towards the database in order to increase the server performance by avoiding unnecessary server trips. Also, with the help of the .NET Base Class Libraries, the complex logical operations can be effectively performed. It deals with automatic garbage collection, memory management, exception handling, etc. due to which it is known as Managed Procedure. The concepts of the OOP can also be applied .It provides the ability to leverage the features of .NET Code Access Security (CAS) to prevent assemblies from performing certain operations.

Annotation 130. comparison of C# Generics and C++ Templates.

1.C# generics and templates in C++ are more or less similar syntactically.
2. C# Generic types are strong typed. C++ Templates are loosely typed.
3. C# Generic types are instantiated at the runtime. C++ templates are instantiated at the compile time.
4. C# Generic types do not permit the type parameters to have default values. C++ templates do.

Annotation 131. an object pool in .NET

An object pool is a container of objects that holds a list of other objects that are ready to be used.
It keeps track of:
1.Objects that are currently in use
2.The number of objects the pool holds
3.Whether this number should be increased
4.The request for the creation of an object is served by allocating an object from the pool.
This reduces the overhead of creating and re-creating objects each time an object creation is required.

The request for the creation of an object is served by allocating an object from the pool.This reduces the overhead of creating and re-creating objects each time an object creation is required.Its access is limited to the types derived from the defining class in the current assembly or the assembly itself.

Annotation 132. Exceptions in .NET

It is a runtime error which occurs because of unexpected and invalid code execution..Net had enhanced exception handling features. All exceptions inherit from System.Exception.

Annotation 133. Custom Exceptions in .NET

Custom Exceptions are user defined exceptions.There are exceptions other than the predefined ones which need to be taken care of. For example: The rules for the minimum balance in a Salary A/C would be different from that in a Savings A/C due to which these things need to be taken care of during the implementation.

Annotation 134. delegates and its application

The delegates in .NET are like the pointers to the functions in C/C++. The difference is that these are type safe unlike the once in C/C++.There are situations where in a programmer or an application needs to perform an action on a particular event. Eg: Some user action like click, text change, etc. So when these actions are performed by the user, the delegates invoke the respective functions.Delegates are like type safe function pointers. We need delegates as they can be used to write much more generic functions which are type safe also.It encapsulates the memory address of a function in the code. Events are created using delegates in .Net. When an event is published/thrown, the framework examines the delegate behind the event and then calls the function that is referred to by the delegate.

Annotation 135.Explain implementation of Delegates in C#

Here is an implementation of a very simple delegate that accepts no parameters.

public delegate void MyDelegate();// Declaration
class MyClass
{
public static void MyFunc()
{
Console.WriteLine(“MyFunc Called from a Delegate”);
}
public static void Main()
{
MyDelegate myDel = new MyDelegate(MyFunc);
myDel();
}
}

Delegate implementation
namespace Delegates
{
public delegate int DelegateToMethod(int x, int y);

         public class Math
         {
                public static int Add(int a, int b)
                {
                      return a + b;
                }

          public static int Multiply(int a, int b)
{
return a * b;
}

          public static int Divide(int a, int b)
{
return a / b;
}
}
public class DelegateApp
{
public static void Main()
{
DelegateToMethod aDelegate = new DelegateToMethod(Math.Add);
DelegateToMethod mDelegate = new DelegateToMethod(Math.Multiply);
DelegateToMethod mDelegate = new DelegateToMethod(Math.Multiply);
DelegateToMethod dDelegate = new DelegateToMethod(Math.Divide);
Console.WriteLine(“Calling the method Math.Add() through the aDelegate object”);
Console.WriteLine(aDelegate(5, 5));
Console.WriteLine(“Calling the method Math.Multiply() through the mDelegate object”);
Console.WriteLine(mDelegate(5, 5));
Console.WriteLine(“Calling the method Math.Divide() through the dDelegate object”);
Console.WriteLine(dDelegate(5, 5));
Console.ReadLine();
}
}
}

Annotation 136. the difference between Finalize() and Dispose()

Dispose() is called by as an indication for an object to release any unmanaged resources it has held.Finalize() is used for the same purpose as dispose however finalize doesn’t assure the garbage collection of an object.Dispose() operates determinalistically due to which it is generally preferred.

Annotation 137. the XmlSerializer and its use in ACL permissions.

The XmlSerializer constructor generates a pair of classes derived from XmlSerializationReader and XmlSerializationWriter by analysis of the classes using reflection.Temporary C# files are created and compiled into a temporary assembly and then loaded into a process.The XmlSerializer caches the temporary assemblies on a per-type basis as the code generated like this is expensive. This cached assembly is used after a class is created.Therefore the XmlSerialize requires full permissions on the temporary directory which is a user profile temp directory for windows applications.

Annotation 138. circular references.

A circular reference is a run-around wherein the 2 or more resources are interdependent on each other rendering the entire chain of references to be unusable. There are quite a few ways of handling the problem of detecting and collecting cyclic references.

1. A system may explicitly forbid reference cycles.
2. Systems at times ignore cycles when they have short lives and a small amount of cyclic garbage. In this case a methodology of avoiding cyclic data structures is applied at the expense of efficiency.
3. Another solution is to periodically use a tracing garbage collector cycles.
Other types of methods to deal with cyclic references are:
a. Weighted reference counting
b. Indirect reference counting

Annotation 139. Explain steps to add controls dynamically to the form.

The following code can be called on some event like page load or onload of some image or even a user action like onclick.

protected void add_button(Button button)
{
try
{
panel1.Controls.Add(button); // Add the control to the container on a page
}
catch (Exception ex)
{
label1.Text += ex.Message.ToString();
}
}

Annotation 140. Extender provider components and its use.

An extender provider is a component that provides properties to other components.

Implementing an extender provider:

1.Use the ProvidePropertyAttribute, which specifies the name of the property that an implementer of IExtenderProvider provides to other components, attribute to specify the property provided by your extender provider.
2.Implement the provided property.
3.Track which controls receive your provided property.
4.Implement the IExtenderProvider, which defines the interface for extending properties to other components in a containe, interface.

Annotation 141. the configuration files in .Net.

The Machine.Config file, which specifies the settings that are global to a particular machine.

This file is located at the following path:
\WINNT\Microsoft.NET\Framework\[Framework Version]\CONFIG\machine.config

The simplest way to add application-specific settings into an application configuration file is to use an application configuration file.
The file is an XML file and contains add elements with key and value attributes.

The authentication section controls the type of authentication used within your Web application Windows, Forms or Passport type of authentication can be defined.

Eg:
or tags can be used with authorization to allow or deny access to your web application to certain users or roles,

Annotation 142. Describe the accessibility modifier “protected internal” in C#.

The Protected Internal access modifier can be accessed by:
1.Members of the Assembly
2.The inheriting class
3.The class itself

Annotation 143. the difference between Debug.Write and Trace.Write

1.Debug.Write: Debug Mode, Release Mode (used while debugging a project)
2.Trace.write: Release Mode (used in Released version of Applications)

Annotation 144. Explain the use of virtual, sealed, override, and abstract.

The virtual keyword enables a class to be overridden. If it has to be prevented from being overridden, then the sealed keyword needs to be used. If the keyword virtual is not used, members of the class can even then be overridden. However, its usage is advised for making the code meaningful. The override keyword is used to override the virtual method in the base class. Abstract keyword is used to modify a class, method or property declaration. You cannot instantiate an abstract class or make calls to an abstract method directly. An abstract virtual method means that the definition of the method needs to bQe given in the derived class.

Annotation 145. Benefits of a Primary Interops Assembly (PIA)

A primary interop assembly contains type definitions (as metadata) of types implemented with COM. Only a single PIA can exist, which needs to be signed with a strong name by the publisher of the COM type library. One PIA can wrap multiple versions of the same type library. A COM type library imported as an assembly can be a PIA only if it has been signed and published by the same publisher. Therefore, only the publisher of a type library can produce a true PIA, that can be considered as the unit of an official type definition for interoperating with the underlying COM types.

Annotation 146. Explain the use of static members with example.

Static members are not associated with a particular instance of any class. They need to be qualified with the class name to be called. Since they are not associated with object instances, they do not have access to non-static members .i.e.: “this” cannot be used, which represents the current object instance.

Annotation 147. How to achieve polymorphism in C#.NET?

Polymorphism is when a class can be used as more than one type through inheritance. It can be used as its own type, any base types, or any interface type if it implements interfaces. It can be achieved in the following ways:
1.Derived class inherits from a base class and it gains all the methods, fields, properties and events of the base class.
2. To completely take over a class member from a base class, the base class has to declare that member as virtual

Annotation 148. Define Code-Access security

Code access security is a mechanism that helps limit the access to the code by protecting the resources. It defines permissions which tell about the rights to access various. It also imposes restrictions on code at run time.
Code:

using System;
namespace ConsoleReadRegistry
{
class SecurityClass
{
[STAThread]
static void Main(string[] args)
{
Microsoft.Win32.RegistryKey regKey;
try
{
regKey =Microsoft.Win32.Registry.LocalMachine.OpenSubKey
(“Software\\Microsoft\\.Net Framework”, false);
string[] skNames = regKey.GetSubKeyNames();
for (int i=0;i
{
Console.WriteLine(“Registry Key: {0}”, skNames[i]);
}
regKey.Close();
}
catch(System.Security.SecurityException e)
{
Console.WriteLine(“Security Exception Encountered: {0}”, e.Message);
}
}
}
}

Annotation 149. Define Role-based security?

Application that provide access to its data based on credentials check, verify the user’s role and hands over the access on the basis of such roles. Managed code finds out the role of a principal through a Principal object. This further contains a reference to an Identity object.

1.User accounts -> represent people
2.Group accounts -> represent certain categories of users and the rights they own.
3.In .NET Framework:- Identity objects represent users, Roles represent memberships and security.

A security principal represents a user and their roles which tells about their authority in the application. Role-based security is mostly used in custom authentication.
Way to set the default policy to the application is:
AppDomain appDomain = AppDomain.CreateDomain (“test”);
appDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

Annotation 150. Explain steps to deploy an XML web service

To deploy the XML Web service, once can add a Web Setup project using project templates or use xcopy to copy the files from the source to the destination server. There onwards, make the destination directory a virtual directory in IIS

Demonstrate how to access unmanaged code using Interop
1.Use System.Runtime.InteropServices.
2.Use DllImport to declare the unmanaged procedure.
3.Map the data types of the procedures parameters to equivalent .NET types.
4.Call the unmanaged procedure.
5.Test it

Annotation 151. Explain the namespaces in which .NET has the data functionality class.

  1. System.Data

The System.Data namespaces contain classes for accessing and managing data from diverse sources. The top-level namespace and a number of the child namespaces together form the ADO.NET architecture and ADO.NET data providers. For example, providers are available for SQL Server, Oracle, ODBC, and OleDB. Other child namespaces contain classes used by the ADO.NET Entity Data Model (EDM) and by WCF Data Services.

The System.Data namespace provides access to classes that represent the ADO.NET architecture. ADO.NET lets you build components that efficiently manage data from multiple data sources.

In a disconnected scenario such as the Internet, ADO.NET provides the tools to request, update, and reconcile data in multiple tier systems. The ADO.NET architecture is also implemented in client applications, such as Windows Forms, or HTML pages created by ASP.NET.

The centerpiece of the ADO.NET architecture is the DataSet class. Each DataSet can contain multiple DataTable objects, with each DataTable containing data from a single data source, such as SQL Server.

Each DataTable contains a DataColumnCollection–a collection of DataColumn objects–that determines the schema of each DataTable. The DataType property determines the type of data held by the DataColumn. The ReadOnly and AllowDBNull properties let you further guarantee data integrity. The Expression property lets you construct calculated columns.

If a DataTable participates in a parent/child relationship with another DataTable, the relationship is constructed by adding a DataRelation to the DataRelationCollection of a DataSet object. When such a relation is added, a UniqueConstraint and a ForeignKeyConstraint are both created automatically, depending on the parameter settings for the constructor. The UniqueConstraint guarantees that values that are contained in a column are unique. The ForeignKeyConstraint determines what action will happen to the child row or column when a primary key value is changed or deleted.

Using the System.Data.SqlClient namespace (the.NET Framework Data Provider for SQL Server), the System.Data.Odbc namespace (the.NET Framework Data Provider for ODBC), the System.Data.OleDb namespace (the.NET Framework Data Provider for OLE DB), or the System.Data.OracleClient namespace (the .NET Framework Data Provider for Oracle), you can access a data source to use together with a DataSet. Each.NET Framework data provider has a corresponding DataAdapter that you use as a bridge between a data source and a DataSet.

Class Description
Constraint Represents a constraint that can be enforced on one or more DataColumn   objects.
ConstraintCollection Represents a collection of constraints for a DataTable.
ConstraintException Represents the exception that is thrown when attempting an   action that violates a constraint.
DataColumn Represents the schema of a column in a DataTable.
DataColumnChangeEventArgs Provides data for the ColumnChanging   event.
DataColumnCollection Represents a collection of DataColumn   objects for a DataTable.
DataException Represents the exception that is thrown when errors are   generated using ADO.NET components.
DataRelation Represents a parent/child relationship between two DataTable   objects.
DataRelationCollection Represents the collection of DataRelation   objects for this DataSet.
DataRow Represents a row of data in a DataTable.
DataRowBuilder Infrastructure. The DataRowBuilder type   supports the .NET Framework infrastructure and is not intended to be used   directly from your code.
DataRowChangeEventArgs Provides data for the RowChanged,   RowChanging,   OnRowDeleting,   and OnRowDeleted   events.
DataRowCollection Represents a collection of rows for a DataTable.
DataRowComparer Returns a singleton instance of the DataRowComparer(Of TRow) class.
DataRowComparer(Of TRow) Compares two DataRow   objects for equivalence by using value-based comparison.
DataRowExtensions Defines the extension methods to the DataRow   class. This is a static class.
DataRowView Represents a customized view of a DataRow.
DataSet Represents an in-memory cache of data.
DataSetSchemaImporterExtension This member supports the .NET Framework infrastructure and is   not intended to be used directly from your code.
DataSysDescriptionAttribute Obsolete. Marks a   property, event, or extender with a description. Visual designers can display   this description when referencing the member.
DataTable Represents one table of in-memory data.
DataTableClearEventArgs Provides data for the Clear   method.
DataTableCollection Represents the collection of tables for the DataSet.
DataTableExtensions Defines the extension methods to the DataTable   class. DataTableExtensions   is a static class.
DataTableNewRowEventArgs Provides data for the NewRow   method.
DataTableReader The DataTableReader   obtains the contents of one or more DataTable   objects in the form of one or more read-only, forward-only result sets.
DataView Represents a databindable, customized view of a DataTable   for sorting, filtering, searching, editing, and navigation.
DataViewManager Contains a default DataViewSettingCollection   for each DataTable   in a DataSet.
DataViewSetting Represents the default settings for ApplyDefaultSort,   DataViewManager,   RowFilter,   RowStateFilter,   Sort,   and Table   for DataViews created from the DataViewManager.
DataViewSettingCollection Contains a read-only collection of DataViewSetting   objects for each DataTable   in a DataSet.
DBConcurrencyException The exception that is thrown by the DataAdapter   during an insert, update, or delete operation if the number of rows affected   equals zero.
DeletedRowInaccessibleException Represents the exception that is thrown when an action is tried   on a DataRow   that has been deleted.
DuplicateNameException Represents the exception that is thrown when a duplicate   database object name is encountered during an add operation in a DataSet   -related object.
EntityCommandCompilationException Represents errors that occur during command compilation; when a command   tree could not be produced to represent the command text.
EntityCommandExecutionException Represents errors that occur when the underlying storage   provider could not execute the specified command. This exception usually   wraps a provider-specific exception.
EntityException Represents Entity Framework-related errors that occur in the EntityClient namespace. The EntityException   is the base class for all Entity Framework exceptions thrown by the EntityClient.
EntityKey Provides a durable reference to an object that is an instance of   an entity type.
EntityKeyMember Represents a key name and value pair that is part of an EntityKey.
EntitySqlException Represents errors that occur when parsing Entity SQL command   text. This exception is thrown when syntactic or semantic rules are violated.
EnumerableRowCollection Represents a collection of DataRow   objects returned from a LINQ to DataSet query. This API supports the .NET   Framework infrastructure and is not intended to be used directly from your   code.
EnumerableRowCollection(Of TRow) Represents a collection of DataRow   objects returned from a query. This API supports the .NET Framework   infrastructure and is not intended to be used directly from your code.
EnumerableRowCollectionExtensions Contains the extension methods for the data row collection   classes. This API supports the .NET Framework infrastructure and is not   intended to be used directly from your code.
EvaluateException Represents the exception that is thrown when the Expression   property of a DataColumn   cannot be evaluated.
FillErrorEventArgs Provides data for the FillError   event of a DbDataAdapter.
ForeignKeyConstraint Represents an action restriction enforced on a set of columns in   a primary key/foreign key relationship when a value or row is either deleted   or updated.
InRowChangingEventException Represents the exception that is thrown when you call the EndEdit   method within the RowChanging   event.
InternalDataCollectionBase Provides the base functionality for creating collections.
InvalidCommandTreeException The exception that is thrown to indicate that a command tree is   invalid. This exception is currently not thrown anywhere in the Entity   Framework.
InvalidConstraintException Represents the exception that is thrown when incorrectly trying   to create or access a relation.
InvalidExpressionException Represents the exception that is thrown when you try to add a DataColumn   that contains an invalid Expression   to a DataColumnCollection.
MappingException The exception that is thrown when mapping related service   requests fail.
MergeFailedEventArgs Occurs when a target and source DataRow   have the same primary key value, and the EnforceConstraints   property is set to true.
MetadataException The exception that is thrown when metadata related service   requests fails.
MissingPrimaryKeyException Represents the exception that is thrown when you try to access a   row in a table that has no primary key.
NoNullAllowedException Represents the exception that is thrown when you try to insert a   null value into a column where AllowDBNull   is set to false.
ObjectNotFoundException The exception that is thrown when an object is not present.
OperationAbortedException This exception is thrown when an ongoing operation is aborted by   the user.
OptimisticConcurrencyException The exception that is thrown when an optimistic concurrency   violation occurs.
OrderedEnumerableRowCollection(Of TRow) This API supports the .NET Framework infrastructure and is not   intended to be used directly from your code. Represents a collection of   ordered DataRow   objects returned from a query.
PropertyCollection Represents a collection of properties that can be added to DataColumn,   DataSet,   or DataTable.
ProviderIncompatibleException The exception that is thrown when the underlying data provider   is incompatible with the Entity Framework.
ReadOnlyException Represents the exception that is thrown when you try to change   the value of a read-only column.
RowNotInTableException Represents the exception that is thrown when you try to perform   an operation on a DataRow   that is not in a DataTable.
StateChangeEventArgs Provides data for the state change event of a .NET Framework   data provider.
StatementCompletedEventArgs Provides additional information for the StatementCompleted   event.
StrongTypingException The exception that is thrown by a strongly typed DataSet   when the user accesses a DBNull value.
SyntaxErrorException Represents the exception that is thrown when the Expression   property of a DataColumn   contains a syntax error.
TypedDataSetGenerator Obsolete. Used to   create a strongly typed DataSet.
TypedDataSetGeneratorException The exception that is thrown when a name conflict occurs while   generating a strongly typed DataSet.
TypedTableBase(Of T) This type is used as a base class for typed-DataTable   object generation by Visual Studio and the XSD.exe .NET Framework tool, and   is not intended to be used directly from your code.
TypedTableBaseExtensions Contains the extension methods for the TypedTableBase(Of T) class.
UniqueConstraint Represents a restriction on a set of columns in which all values   must be unique.
UpdateException The exception that is thrown when modifications to object   instances cannot be persisted to the data source.
VersionNotFoundException Represents the exception that is thrown when you try to return a   version of a DataRow   that has been deleted.

a

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s