Saturday, November 5, 2011

Q1.  What is the output if code snippet 3 is executed (consider definitions of code snippet 1 and code snippet 2 too to find your answer)?

interface IA


{
        void Goto();
}

class mybase

{
       void Goto()
        {
               Console.WriteLine("inside mybase constructor.");
        }
}

What is the output of the following code block ?

class  myderivedmybaseIA
{
        
}

a) Does it compiles successfully? or Does it throw any error?
b) Do we need to provide definition of method Goto() in class A()?

Q2. Do we need to define method named Goto() in class "myderived"? or that is not needed ? consider following code?



interface IA
{
        void Goto();
}
interface IB
{
        void Goto();
}
class  mybase
{
        public void Goto()
        {
            Console.WriteLine("inside mybase constructor.");
        }
}
class  myderivedmybase ,IA
{
       //    Does this code compile and run successfully?      
}


a)  Does this code compile and run successfully?      
b) What happens if the keyword "public" is removed from Goto() method defination in "mybase" class?
c) What happens when in interface "IB", the signature of the method "void Goto()" is changed to some other say "int Goto()" keeping everything same? Does "myderived" is compiled successfully or it throws any error?










Thursday, February 17, 2011

How To Drop Already Created Index in a sdf file(SQL CE)

Today I had to delete an index already created in a table in a SQL CE database, i.e in a sdf file.
The problem of deleteing/droping an already created index in a table in sdf file is that (1) if you have opened it in SQL Server 2005 editor or (2) using Visual Studio editor, you can not just delete/drop the index though both editor provides you an option for deleteing / droping using content menu item.

The bottom line is, you just can not delete/drop an already created Index in a table in sdf file using either SQL Server 2005 editor or Visual Studio editor.

An already created Index in a table in sdf file can only be dropped/deleted using a query as explained following,
=========================================================

DROP INDEX "TABLE_NAME"."INDEX_NAME"

Where "TABLE_NAME" is the name of the table to which index belong to.
"INDEX_NAME" is the name of the already created index which we want to delete/drop.

=========================================================

Example : If you have a table named "CUSTOMER_POSM_REQUEST" and already existing Index name is "RECORD_ID_INDEX" then as mentioned above, the query would be like this:

DROP INDEX CUSTOMER_POSM_REQUEST.RECORD_ID_INDEX

=========================================================

Use the above query and run the query in either of the editor mentioned above. Index will be deleted. Not sure what is the reason behind that. Need to dig it further :)