What does partial trust mean the Web Part developer?

If an assembly is installed into the BIN directory, the code must be ensured that provides error
handling in the event that required permissions are not available. Otherwise, unhandled ecurity exceptions may cause the Web Part to fail and may affect page rendering on the page where the Web Part appears.

Does a SharePoint Web site include search functionality?

Yes. SharePoint Team Services provides a powerful text-based search feature that helps you find documents and information fast.

What are the features of the new Content management in Office SharePoint 2007?

The new and enhanced content management features in Office SharePoint Server 2007 fall within three areas:
* Document management
* Records management
* Web content management

Office SharePoint Server 2007 builds on the core document management functionality provided by Windows SharePoint Services 3.0, including check in and check out, versioning, metadata, and role-based granular access controls. Organizations can use this functionality to deliver enhanced authoring, business document processing, Web content management and publishing, records management, policy management, and support for multilingual publishing.

What are the advanced features of MOSS 2007?

* User Interface (UI) and navigation enhancements
* Document management enhancements
* The new Workflow engine
* Office 2007 Integration
* New Web Parts
* New Site-type templates
* Enhancements to List technology
* Web Content Management
* Business Data Catalog
* Search enhancements
* Report Center
* Records Management
* Business Intelligence and Excel Server
* Forms Server and InfoPath
* The “Features” feature
* Alternate authentication providers and Forms-based authentication

What’s New in SQL Server 2008 XML SQL Server 2008

SQL Server 2008 provides several enhancements over SQL Server 2000 in terms of XML support and some enhancements over SQL Server 2005. While much of the backward-compatible XML-specific functionality from SQL Server 2000 is available in SQL Server 2008, most of it has been deprecated in favor of the new features and functionality. This section gives a broad overview of the major enhancements to XML support, which include the following items:

• New xml data type
• XML schema collections
• XML indexes
• FOR XML enhancements, including XPath support in the FOR XML PATH clause
• XQuery and XML DML support
• SQLCLR xml data type support
• Improvements to legacy XML functionality, including improvements to the sp_xml_preparedocument procedure
• HTTP Simple Object Access Protocol (SOAP) endpoints
SQL Server 2008 provides several enhancements over SQL Server 2000 in terms of XML support and some enhancements over SQL Server 2005. While much of the backward-compatible XML-specific functionality from SQL Server 2000 is available in SQL Server 2008, most of it has been deprecated in favor of the new features and functionality. This section gives a broad overview of the major enhancements to XML support, which include the following items:
• New xml data type
• XML schema collections
• XML indexes
• FOR XML enhancements, including XPath support in the FOR XML PATH clause
• XQuery and XML DML support
• SQLCLR xml data type support
• Improvements to legacy XML functionality, including improvements to the
sp_xml_preparedocument procedure
• HTTP Simple Object Access Protocol (SOAP) endpoints

Incorrect Mixing of Equality Operators

Compile-time checking can be helpful in working with the incorrect mixing of equality operators. Consider the following code fragment:
void foo( int a , int b )
{
if ( a = b )
{
/* some code here */
}
}
This kind of error can be very difficult to spot! Instead of comparing the variables, this function sets a to the value of b and executes the conditional value if b is nonzero! This action is probably not what the programmer intended (although it might be). Not only will the code be executed at the wrong times, but the value of a will be wrong when it is used later.

Implicit Casting of Variables

The C language will in some cases implicitly cast variables of one type into another. Sometimes this is a good thing (it saves the programmer from having to perform this task), but it can have unintended behavior.

Perhaps the worst implicit cast is that of pointer-to-integer.
void sort( int ar[] , int size )
{
/* code to sort goes here */
}
int main()
{
int array[ 10 ];
sort( 10 , array );
}

What is Assert() command

In any program, there are some conditions that should never occur. These conditions include division by zero, writing to the null pointer, and so forth. You want to be informed whenever such conditions occur in your program, and furthermore, you want know exactly where they occur.
The C language comes with such a construct, in the form of the assert() command. The assert() command tests the condition inside its parentheses, and if the condition is false, it takes these steps:
1. Prints the text of the condition that failed.
2. Prints the line number of the error.
3. Prints the source code file that contains the error.
4. Causes the program to terminate with an error condition.

What is Assert() command

In any program, there are some conditions that should never occur. These conditions include division by zero, writing to the null pointer, and so forth. You want to be informed whenever such conditions occur in your program, and furthermore, you want know exactly where they occur.
The C language comes with such a construct, in the form of the assert() command. The assert() command tests the condition inside its parentheses, and if the condition is false, it takes these steps:
1. Prints the text of the condition that failed.
2. Prints the line number of the error.
3. Prints the source code file that contains the error.
4. Causes the program to terminate with an error condition.

Debug a TSR program

A TSR (terminate and stay resident) program is one that, after executing, remains resident in the computer’s memory and continues to carry out some task. It does so by making some element of the computer’s operating system periodically invoke the code that the TSR program has caused to remain resident in the computer’s memory.

The way that TSR programs operate makes them very hard to debug! This is because, to the debugger, the program only truly executes for a very short period. The debugger really has no way of knowing exactly what the program is doing, and it has no way of knowing that the TSR program continues to run after it appears to have terminated. The very “invisibility” that makes TSRs so useful can cause immense problems! Furthermore, the process whereby the program makes itself resident in memory, by changing vectors, by changing the size of free memory, and by other methods, can catastrophically interfere with the execution of the debugging program. It is also possible that the debugger might clobber the changes that the TSR has made.
In any case, unless you have a debugger specifically developed for TSR programs, using a debugger probably will not be possible. There are, however, other methods of debugging TSR programs.

First, you can reuse a method described earlier, namely, that of using print statements to monitor the progress of a program, but with slight modifications. Whenever the TSR program is invoked by the system by whatever method is chosen (keystroke, timer interrupt, and so on), you can open a log file in append mode and print messages to it that inform the programmer about the execution of the program. This could include functions that the flow of execution encounters, the values of variables, and other information. After the TSR program is finished running (or it crashes), you can examine the log file and gain valuable insight into the problem.

Another method is to create a “dummy” TSR program. In other words, create a program that would function as a TSR, but don’t make it one! Instead, make it a subroutine of a testing program. The function that would normally accept the system interrupts could easily be modified to accept function calls from the main program. The main program could contain “canned” input that it would feed to the TSR, or it could accept input dynamically from the programmer. Your code, which otherwise behaves like a TSR, never installs itself
in computer memory or changes any of the operating system’s vectors.

The second method has several major benefits. It enables the programmer to use his customary debugging techniques and methods, including debuggers. It also gives the programmer a better way to watch the internal operation of his program. Furthermore, real TSR programs install themselves in memory and, if they are not removed, permanently consume a section of the computer’s memory. If your program is not debugged, there is, of course, a chance that it is not removing itself from computer memory properly. This would otherwise lead to complete exhaustion of computer memory (much like a memory leak).

Why Use WebLogic JMS Instead

The standards of Java 2 Enterprise Edition (J2EE), WebLogic Server provides flexible out-of-the-box support for foreign JMS providers. But for most applications, the JMS support built in to WebLogic Server is easier to use, configure, and monitor, and it provides performance and features that meet or exceed those of competing JMS vendors. Some reasons to use We-bLogic JMS are: WebLogic JMS runs as an integral part of WebLogic Server. On the other hand, a foreign JMS provider must be configured, started, stopped, and monitored using a totally separate set of tools. WebLogic JMS is integrated with the built-in JNDI and clustering support of WebLogic Server. There is no need to configure and manage a separate JNDI infrastructure, whether it is a collection of files or an LDAP server. WebLogic JMS provides strict conformance with the JMS specification, so applications may be written in a portable way.

Why Use a Foreign JMS Provider?

Customers sometimes need to use a different JMS provider from WebLogic JMS. Some of the reasons for doing this are: Legacy system access. It may be necessary to use a foreign JMS provider because only that software provides access to a particular legacy system, because only that software connects to a platform where WebLogic Server is not available. Message forwarding. Some customers may need to forward messages between a foreign JMS provider and WebLogic JMS, or even between two foreign JMS providers. In WebLogic Server 6.1 SP3 and 7.0, this can be accomplished without programming by using the Web-Logic Messaging Bridge. In addition, this document describes some ways to do this without using the bridge. Some customers may want to use two-phase commit when they do this in order to eliminate the possibility of losing or duplicating a message. Driving message-driven beans. Some customers, especially those who need to access messages from legacy systems, may need to use a foreign JMS provider to supply messages to a message-driven bean.

Basic MQSeries Concepts

Basic MQSeries Concepts Like other client-server systems, MQSeries consists of two major components: a server (called the “queue manager”) and a client. The queue manager consists of a number of processes that use shared memory to communicate with each other. It is responsible for storing messages either in memory or on the disk (in the case of persistent messages). A third component, the pub-lish/subscribe broker, is a separate application that uses the MQSeries API to forward pub-lish/subscribe messages. It must be installed and started separately if publish/subscribe is to be used.

New Features in WebLogic Server 7.0

Version 7.0 of WebLogic Server provides several features that make it easier to integrate with foreign JMS providers.

WebLogic Messaging Bridge

The WebLogic Messaging Bridge is a part of WebLogic Server that forwards messages from a “source” destination to a “target” destination. Out-of-the-box adapters are provided so that the source and/or target may be a JMS destination. Either end can be a JMS topic or queue, and could be a server running WebLogic Server 5.1 or higher, or a foreign JMS provider. The WebLogic Messaging Bridge also provides interoperability between different versions of WebLogic Server. The WebLogic Messaging Bridge supports two-phase commit transactions using XA for JMS providers that support it, and one-phase commit transactions for providers that do not.

Container-Managed Transactions for Message-Driven Beans

A message-driven bean (MDB) is a special type of Enterprise Java Bean (EJB) that pulls mes-sages from a JMS queue or topic. The EJB container (WebLogic Server) is responsible for connecting to the JMS provider, receiving messages, and passing them to the MDB in the proper transaction context. This allows asynchronous events to be processed by a J2EE-based applica-tion, which was not possible in a standard way before MDBs.. WebLogic Server has supported MDBs since WebLogic Server 6.0. Version 6.0 SP1 of the server added support for foreign JMS providers. However, container-managed transactions could only be used with WebLogic JMS, so a foreign JMS provider could not participate in the WebLogic transaction. WebLogic Server 7.0 allows foreign JMS providers to participate in a WebLogic transaction. If the MDB is set up to support container-managed transactions, and if the JMS provider is config-ured to support XA, then WebLogic Server will use XA to include the JMS provider in the overall WebLogic transaction. This way, it is possible to deploy an MDB that supports “Exactly-once” transactional guarantees, thereby ensuring that each message will be processed once and only once.

Java Command:Creating a key pair and keystore

>cd %JAVA_HOME%\bin
>keytool -genkey -keystore mykeys.jks -alias gene
Enter keystore password: mykeystorepassword
What is your first and last name?
[Unknown]: Gene Telluride
What is the name of your organizational unit?
[Unknown]: Information Technologies
What is the name of your organization?
[Unknown]: The Daily Moon
What is the name of your City or Locality?
[Unknown]: New York
What is the name of your State or Province?
[Unknown]: NY
What is the two-letter country code for this unit?
[Unknown]: US
Is CN=Gene Telluride, OU=Information Technologies, O=The Daily
Moon,
L=New York, ST=NY, C=U
S correct?
[no]: yes
Enter key password for
(RETURN if same as keystore password): mypassword

Best practice #4: Recycle your resources

Invariably, applications waste too much time fetching, creating, or destroying some complex objects or resources. Others may be too expensive for a single application to maintain on a one-to-one basis. Therefore, you should create a limited number of the resource, and share them from a common pool. You can pool many types of resources, from complex objects to connections. J2EE will manage some of these for you. For example, J2EE connection pools can improve performance by an order of magnitude for extreme cases.

Best Practice#3: Use a Standard Modeling Language

Designers and Developers, as well as everyone involved in the development process, need to be able to communicate clearly with one another. To improve communication, you need a common language to articulate the design of application components.

Best practice #2: Design for change with Dynamic Domain Model

Modern developers need to have domain models that are nimbly changed. With the emergence of iterative development and shorter development cycles, there is almost certainty that changes to an application will occur after the initial design. To effectively handle changes, developers shouldn’t have to completely rework tested code. An application needs to be able to nimbly handle changes in a way that ensures a high level of quality.

Best practice #1: Attack risk as early as possible

The risk associated with application development seems to rise exponentially with complexity. While it may seem hopeless, there are some things that you can do to mitigate your risks. From a process perspective, perhaps the most important risk mitigation involves moving risk to the front of the schedule, reducing your risk in three ways:

· Improving knowledge. The biggest risks will always be associated with the unknown. Earlier knowledge will allow you to make more informed decisions and better schedules through the remainder of development cycle.

· Allowing recovery time. If you’re going to fail, it’s better to fail early, while there’s
still time to recover.

· Involving the customer early. Your customer’s response to a user interface or key capability can dramatically impact the direction of a project. Inspiring confidence early improves your relationships.

C# basics

1) Single inheritance means that a C# class can inherit from only one base class.

2) C# enables you to group your classes into a collection of classes called a namespace.
Namespaces have names, and can help organize collections of classes into logical groupings.

3) C# lets you work with two types of data: value types and reference types. Value types hold
actual values. Reference types hold references to values stored elsewhere in memory.

4) Primitive types such as char, int and float, as well as enumerated values and structures, are
value types. Reference types hold variables that deal with objects and arrays

5) You can work with both one-dimensional and multidimensional arrays in C#.
Multidimensional arrays can be rectangular, in which each of the arrays has the same
dimensions, or jagged, in which each of the arrays has different dimensions.

6) Functions can have four kinds of parameters:

• Input parameters have values that are sent into the function, but the function cannot
change those values.
• Output parameters have no value when they are sent into the function, but the function
can give them a value and send the value back to the caller.
• Reference parameters pass in a reference to another value. They have a value coming
in to the function, and that value can be changed inside the function.
• Params parameters define a variable number of arguments in a list.


7) Enum type declarations specify a type name
for a related group of constants, Using the enum names in code makes code more readable

8) C# provides a built-in mechanism for defining and handling events. If you write a class that
performs a lengthy operation, you may want to invoke an event when the operation is
completed. Clients can subscribe to that event and catch the event in their code, which enables
them to be notified when you have completed your lengthy operation. The event handling
mechanism in C# uses delegates, which are variables that reference a function.

9) You can write a piece of code called an indexer to enable your class to be accessed
as if it were an array. Suppose you write a class called Rainbow, for example, that contains a
set of the colors in the rainbow. Callers may want to write MyRainbow[0] to retrieve the first
color in the rainbow. You can write an indexer into your Rainbow class to define what should
be returned when the caller accesses your class, as if it were an array of values.

10) Attributes declare additional information about your class to the CLR. Attributes
enables you, the developer, to bind information to classes. Attributes can also be used to bind runtime information to a class

11) The code that is output by the C# compiler is written in a language called Microsoft
Intermediate Language, or MSIL

12) All .NET-compatible languages, including Visual Basic .NET and Managed C++,
produce MSIL when their source code is compiled. Because all of the .NET languages
compile to the same MSIL instruction set,

13) MSIL code is turned into
CPU-specific code when the code is run for the first time. This process is called "just-in-time"
compilation, or JIT. The job of a JIT compiler is to translate your generic MSIL code into
machine code that can be executed by your CPU.

14) The compilation process also outputs metadata, Think of metadata as a "table of contents" for your compiled code. The C# compiler places
metadata in the compiled code along with the generated MSIL. This metadata accurately
describes all the classes you wrote and how they are structured.


15) An assembly is a package of code and metadata. When you deploy a set of classes in an
assembly, you are deploying the classes as a unit; and those classes share the same level of
version control, security information, and activation requirements. Think of an assembly as a
"logical DLL."

16) There are two types of assemblies: private assemblies and global assemblies. When you build
your assembly, you don't need to specify whether you want to build a private or a global
assembly. The difference is apparent when you deploy your assembly. With a private
assembly, you make your code available to a single application.

17) The .NET Framework contains a list of global assemblies in a facility
called the global assembly cache, and the .NET Microsoft Framework SDK includes utilities
to both install and remove assemblies from the global assembly cache. GAC


18) Every application in C# must have a method called Main().

19) public static void Main()

By declaring your Main() method as public, you are
creating an entry point for Windows to start the application when a user wants to run it.

The word Static in the method declaration means that the compiler should allow only one
copy of the method to exist in memory at any given time. Because the Main() method is the
entry point into your application, it would be catastrophic to allow the entry point to be loaded
more than once

Void means that your application returns no value after it has
completed. This sample application isn't very advanced, so no return value is needed; under
normal circumstances, however, the Main() function would typically return an integer value
by replacing the word void with int.

20) The C# compiler does not ordinarily allow you to use any of the reserved keywords as an
identifier name. You'll get an error if, for example, you try to name a class static. If you really
need to use a keyword name as an identifier, however, you can precede the identifier with the
@ symbol. This overrides the compiler error and enables you to use a keyword as an
identifier.

21) The C# compiler does, in fact, accept any
of four possible constructs for the Main() function:
• public static void Main()
• public static void Main(string[] Arguments)
• public static int Main()
• public static int Main(string [] Arguments)

The second form, public static void Main(string[] Arguments), does not return a value to the
caller. It does, however, take in an array of strings. Each string in the array corresponds to a
command-line argument supplied when the program executes.

22) C# makes a distinction between assigned and unassigned variables. Assigned variables are
given a value at some point in the code, and unassigned variables are not given a value in the
code. Working with unassigned variables is forbidden in C#, because their values are not
known and using the variables can lead to errors in your code. HOWEVER In some cases, C# gives default values to variables. A variable declared at the class level is
one such case.

23) C# enables you to group variables into structures. By defining a structure for your data, the
entire group can be managed under a single structure name, regardless of the number of
variables that the structure contains. The entire set of variables can be easily manipulated by
working with a single structure, rather than having to keep track of each individual variable
separately

24) Structures in C# are value types, not reference types. This means that structure variables
contain the structure's values directly, rather than maintaining a reference to a structure found
elsewhere in memory.

25) Structures may also be made up of variables of different types.

struct Employee
{
public string FirstName;
public string LastName;
public string Address;
public string City;
public string State;
public ushort ZIPCode;
public decimal Salary;
}

As with all statements in C#, you can declare a structure only from within a class.
you can then use it like:

Employee emp;
emp.Firstname

26) C# does not allow you to initialize structure
members when they are declared. Take a look at the error in the following code:
struct Point
{
public int X = 100;
public int Y = 200;
}
This declaration produces errors from the compiler:
error CS0573: 'MyClass.Point.X': cannot have instance field
initializers in structs
error CS0573: 'MyClass.Point.Y': cannot have instance field
initializers in structs

You can use a special method called a constructor to initialize structure members to nonzero
values.


27) If you want to invoke a constructor on a structure, you must use the new keyword, followed by the
name of the structure,

Point MyThirdPoint = new Point(250, 475);

This statement says: "Create a new Point structure using the constructor with two integers.
Assign its value to the MyThirdPoint variable.

28) The parameterless constructor syntax is also shown in Listing 7-3:

Point MyFirstPoint = new Point();

This tells the C# compiler that you want to initialize the structure using its default behavior.

29) You may also write methods in your structures. These methods follow the same rules as class
methods:

30) Properties within a structure enable you to read, write, and compute values with the use of
accessors. Unlike fields, properties are not considered variables; therefore, they do not
designate storage space. Because a property does not allocate storage space, it cannot be
passed as a ref or out parameter.

31) Interfaces are a way of ensuring that someone using your class has abided by all the rules you
set forth to do so. This can include implementing certain methods, properties, and events.
When you expose an interface, users of your interface must inherit that interface; and in doing
so, they are bound to create certain methods and so forth. This ensures that your class and/or
structure is used as it was intended.
You can include an interface within a structure as well.

Oops Basics part 3

21) why have interfaces?

There are often situations in which we need to know that the class implements certain features in order to be able to use a class in a certain way. An example is provided by the foreach loop in C#. In principle, it is possible to use foreach to iterate through a class instance, provided that that class is able to act as if it is a collection. How can the .NET runtime tell whether a class instance represents a collection? It queries the instance to find out whether it implements the System.Collections.IEnumerable interface.
If it does, then the runtime uses the methods on this interface to iterate through the members of the collection. If it doesn’t, then foreach will raise an exception.


A second reason for using interfaces is for interoperability with COM. Before the advent of .NET, COM, and its later versions DCOM and COM+, provided the main way that applications could communicate with each other on the Windows platform, and the particular object model that COM used was heavily dependent on interfaces. Indeed, it was through COM that the concept of an interface first became commonly known.

However, that C# interfaces are not the same as COM interfaces. COM interfaces have very strict requirements, such as that they must use GUIDs as identifiers, which are not necessarily present in C# interfaces. However, using attributes, it is possible to dress up a C# interface so it acts like a COM interface, and hence provide compatibility with COM.



22) Construction and Disposal

Most modern OOP languages support the ability to construction and destruction of objects.

This support happens through something called a constructor. A constructor
is a special method called automatically whenever an object of a given class is created. You don’t
have to write a constructor for a class, but if you want some custom initialization to take place automatically, you should place the relevant code in the constructor.

Similarly, A destructor is a method called automatically whenever an object is destroyed (the variable goes out of scope). Reclaiming memory aside, destructors are particularly useful for classes that represent a connection to a database, or an open file, or those that have methods to read from and write to the database/file. In that case, the destructor can be used to make sure that you don’t leave any database connections or file handle hanging open when the object goes out of scope.

23 ) It’s not necessary to provide a constructor for your class, far. In general, if you don’t explicitly supply any constructor, the compiler will just make up a default one for you behind the scenes. It’ll be a very basic constructor that just initializes all the member fields to their normal default values (empty string for strings, zero for numeric data types, and false for bools).

Oops basics part 2

we aim to write easily maintainable and reusable pieces of code that can perform collectively very complex tasks.

11) Properties :

Properties are in extremely common use, and can significantly simplify the external user interface exposed by classes. Properties exist for the situation in which you want to make a method call look like a field. A property is a method or pair of methods that are exposed to the outside world as if they are fields.

Example :


12) Data encapsulation :
In OOP, we aim to make it so that users of objects only need to know what an object does, not how it does it. So making fields directly accessible to users defeats the ideology behind OOP.

If we make fields directly visible to external users, we lose control over what they do to the fields. They might modify the fields in such a way as to break the intended functionality of the object (give the fields in appropriate values, let’s say).

However, if we use properties to control access to a field, this is not a problem because we can add functionality to the property that checks for inappropriate values. Related to this, we can also provide read-only properties by omitting the set accessor completely. The principle of hiding fields from client code in this way is known as data encapsulation.


13) Inheritance

C# is it supports both types of inheritance. implementation inheritance & interface inheritence

Example

public class Nevermore60Customer : Customer
{
}
This tells the compiler that Nevermore60Customer is derived from Customer or we can say that each member of Customer is inherited in Nevermore60Customer. Also, Nevermore60Customer is said to be a derived class, while Customer is said to be the base class

The base class itself is never implicitly modified in any way by the existence of the derived class. This must always be the case, because when you code the base class, you don’t necessarily know what other derived classes might be added in the future—and you wouldn’t want your code to be broken when someone adds a derived class!

Override keyword :

access modifier protected :

It indicates that any class that is derived
from Customer, as well as Customer itself, should be allowed access to this member. The member is still invisible, however, to code in any other class that is not derived from Customer. Essentially, we’re assuming that, because of the close relationship between a class and its derived class, it’s fine for the derived class to know a bit about the internal workings of the base class, at least as far as protected members are concerned.


virtual keyword:

C# will not allow derived classes to override a method unless that method has been declared as virtual in the base class.



Note : As a rule that is enforced by .NET and C#: All .NET classes must ultimately derive from a base class called Object. In C# code, if you write a class and do not specify a base class, the compiler will supply System.Object as the base class by default.

This means that all objects in the .NET Framework have certain methods inherited from the Object class, including the ToString() and GetType() methods



14 ) Single and multiple inheritance :

In C#, each derived class can only inherit from one base class (although we can create as many different classes that are derived from the same base class as we want). The terminology to describe this is single inheritance. Some other languages, including C++, allow you to write classes that have more than one base class, which is known as multiple inheritance.

15) Method Hiding

Even if a method has not been declared as virtual in a base class, it is still possible to provide another method with the same signature in a derived class. The signature of a method is the set of all information needed to describe how to call that method: its name, number of parameters, and parameter types. However, the new method will not override the method in the base class. Rather, it is said to hide the base class method.

If a method hides a method in a base class, then you should normally add the keyword new to its definition. Not doing so does not constitute an error, but it will cause the compiler to give you a warning.

16) Abstract class

Every time you defined a class you will actually create instances of that class, but that’s not always the case. In many situations, you’ll define a very generic class from which you intend to derive other, more specialized classes but don’t ever intend to actually use. C# provides the keyword abstract for this purpose. If a class is declared as abstract it is not possible to instantiate it.

Example :

abstract class MyBaseClass

In this case the following statement will not compile:

MyBaseClass MyBaseRef = new MyBaseClass();

However, it’s perfectly legitimate to have MyBaseClass references, so long as they only point to derived classes. For example, you can derive a new class from MyBaseClass:

class MyDerivedClass : MyBaseClass
{
...
In this case, the following is perfectly valid code:

MyBaseClass myBaseRef;
myBaseRef = new MyDerivedClass();

17) Abstract methods

It’s also possible to define a method as abstract. This means that the method is treated as a virtual method, and that you are not actually implementing the method in that class, on the assumption that it will be overridden in all derived classes. If you declare a method as abstract you do not need to supply a method body:

Note : If any method in a class is abstract, then that implies the class itself should be abstract, and the compiler will raise an error if the class is not so declared. Also, any non-abstract class that is derived from this class must override the abstract method. These rules prevent you from ever actually instantiating a class that doesn’t have implementations of all its methods.


18) What is the use of abstract methods and classes?

They are extremely useful for two reasons. One is that they often allow a better design of class hierarchy, in which the hierarchy more closely reflects the situation you are trying to model. The other is that the use of abstract classes can shift certain potential bugs from hard-to-locate runtime errors into easy-to-locate compile-time errors.


19) Sealed Classes and Methods

Methods and classes that cannot be overridden or inherited from.C# also supports declaring an individual override method as sealed, preventing any further overrides
of it.

The most likely situation when you’ll mark a class or method as sealed will be if it is very much internal to the operation of the library, class, or other classes that you are writing, so you are fairly sure that any attempt to override some of its functionality causes problems. You might also mark a class or method as sealed for commercial reasons, in order to prevent a third party from extending your classes in a manner that is contrary to the licensing agreements.


20) Interfaces

In general, an interface is a contract that says that a class must implement certain features (usually methods and properties), but which doesn’t specify any implementations of those methods and properties. Therefore you don’t instantiate an interface; instead a class can declare that it implements one or more interfaces. In C#, as in most languages that support interfaces, this essentially means that the class inherits from the interface.

Example :

interface IEnumerator
{
// Properties
object Current {get; }

// Methods
bool MoveNext();
void Reset();
}

Oops basics part 1

we aim to write easily maintainable and reusable pieces of code that can perform collectively very complex tasks.

1) An object is anything that is identifiably a single material item. An object can be a car, a
house, a book, a document or a car radio. Most people don’t know exactly how a car radio works; however, they do know what it does and how to operate it.

2) In programming we break each program into lots of units and design each unit to perform a clearly specified role within the program. That’s basically what an object is.

3) If oops principals are used properly while programming then it becomes easier for multiple developers to work together, since they can work on different objects in the code; all they need to know is what an object can do and how to interface with it. They don’t have to worry about the details of how the underlying code works.

4) Difference between a class and object

In programming, we need to distinguish between a class and an object. A class is the generic definition of what an object is—a template. For example, a class could be “car radio”—the abstract idea of a car radio. The class specifies what properties an object must have to qualify as a car radio.


5) Class members

In general, a class is defined by its fields and methods. there are two sides to an object: what it does, which is usually publicly known, and how it works, which is usually hidden.
In programming, the “what it does” is normally represented in the first instance by methods, which are blocks of functionality that you can use. A method is just C# parlance for a function. The “how it works” is represented both by methods and by any data (variables) that the object stores. In C# the terminology is fields

6) Access Modifiers

Marking a field or method as private effectively ensures that that field or method will be part of the internal working of the class, as opposed to the external interface. The advantage of this is that if you d ecide to change the internal working (perhaps you later decide not to store password as a string but to use some other more specialized data type), you can just make the change without breaking the code out side the Authenticator class definition—nothing from outside of this class can access this field.



7) Creating a class instance

Authenticator myAccess = new Authenticator();

[ = new Authenticator() ] is a part of C# syntax, and is there because in C#, classes are always
accessed by reference.

We could actually use the following line if we just wanted to declare a new Authenticator object called myAccess:

Authenticator myAccess;

This declaration can hold a reference to an Authenticator object, without actually creating any object (in much the same way that the line Dim obj As Object in Visual Basic doesn’t actually create any object).

The new operator in C# is what actually instantiates an Authenticator object.




8) Why do we decalre some fields as static?

To indicate that a field should only be stored once, no matter how many instances of the class we create, we place the keyword static in front of the field declaration in our code:

private static uint minPasswordLength = 6;

By declaring the field as static, we ensure that it is only stored once, and this field is shared among all instances of the class. Fields declared with the static keyword are referred to as
static fields or static data, while fields that are not declared as static are referred to as instance fields or instance data

Important : If a field has been declared as static, then it exists when your program is running from the moment that the particular module or assembly containing the definition of the class is loaded—that is as soon as your code tries to use something from that assembly, so you can always guarantee a static variable is there when you want to refer to it. This is independent of whether you actually create any instances of that class. By contrast, instance fields only exist when there are variables of that class currently in scope—one set of instance fields for each variable.


Also : static keyword is independent of the accessibility of the member to which it
applies. A class member can be public static or private static.

Also : However, just as with fields, it is possible to declare methods as static, provided that they do not attempt to access any instance data or other instance methods.



9) Ovwerloading a method :

To overload a method is to create several methods each with the same name, but each with a different signature. The reason why you might want to use overloading is best explained with an example. Consider how in C# we write data to the command line, using the Console.WriteLine() method.

Console.WriteLine() can display int, strings and lot of other datatypes since there are many Console.WriteLine() overloads

When to use overloading : Generally, you should consider overloading a method when you need a number of methods that take different parameters, but conceptually do the same thing, as with Console.WriteLine() above.


10) Different output types : Out parameter

occasionally you might have a method that calculates or obtains some quantity, and depending on the circumstances, you might want this to be returned in more than one way. You cannot distinguish overloads using the return type of a method. However, you can do so using out parameters.

void GetAircraftLocation(DateTime Time, out string Location)
{
...
}
void GetAircraftLocation(DateTime Time, out float Latitude, out float Longitude)
{
...
}

Note: however, that in most cases using overloads to obtain different out parameters does not lead to an architecturally neat design. In the above example, a better design would perhaps involve defining a Location struct that contains the location string as well as the latitude and longitude and returning this from the method call, hence avoiding the need for overloads.