Note: All this data has been copied from various sources for the purpose of knowledge sharing. Data content can be either as it is or with little modification.
---------------------------------------------------------------------------------------------------------------------
1. What is store procedures
---------------------------------------------------------------------------------------------------------------------
1. What is store procedures
set of Structured Query Language (SQL) statements that perform particular task.SP increase the security to application, it protect from Sql injection and hacking.
Stored procedure have two types of parameters.
a) Output Type Parameter
b) Input Type Parameter.
In SQL we are having different types of stored procedures are therea) System Stored Proceduresb) User Defined Stored procedures
*************************
SP may return one or more values through parameters or may not return at all.SP can return multiple values (max 1024).We can use try catch statements in stored procedures.
Disadvantages:
•Lack of portability. Stored procedures are not portable from one brand of database to another. For example, SQL Server and Sybase cannot run stored procedures created for Oracle, and Oracle cannot run stored procedures created for SQL Server or Sybase.
•Potential for reduced performance. Overburdening the server with stored procedure processing, in addition to standard RDBMS tasks, may degrade database performance.
•Difficult debugging. Nested stored procedures (stored procedures called by other stored procedures) are difficult to debug. Stored procedures invoked from event‑driven triggers are even more difficult to debug.
•Reduced stability. If a stored procedure that was installed as an external DLL and run within the address space of the database engine fails, the server may also fail.
*********************************
*********************************
2. What are generics?
Generics refers to a technique of writing a class without specifying the data type that the class works with. Your code can then declare an instance of such a class and specify the data type. This allows generics classes to be used with many different data types without needing to be rewritten.
******************************
Generics allow you to delay the specification of the data type of programming elements in a class or a method, until it is actually used in the program. In other words, generics allow you to write a class or method that can work with any data type.You write the specifications for the class or the method, with substitute parameters for data types. When the compiler encounters a constructor for the class or a function call for the method, it generates code to handle the specific data type
******************************
Generics allow you to delay the specification of the data type of programming elements in a class or a method, until it is actually used in the program. In other words, generics allow you to write a class or method that can work with any data type.You write the specifications for the class or the method, with substitute parameters for data types. When the compiler encounters a constructor for the class or a function call for the method, it generates code to handle the specific data type
static void Main(string[] args)
{
Generic<string> g = new Generic<string>();
g.Field = "A string";
//...
Console.WriteLine("Generic.Field = \"{0}\"", g.Field);
Console.WriteLine("Generic.Field.GetType() = {0}", g.Field.GetType().FullName);
Console.WriteLine();
Console.ReadKey();
}
public class Generic<T>
{
public T Field;
}
******************************
A collection is simply a collection of whatever. Object, strings, integers, Persons, all of the above...Collections can hold different data type. Here all the elements are objects. In generics, we can specify which datatype we want to store.That might still not be very simple. But basically a 'Generic' is a method to make something work with ANY type. The pro's to this are, as already mentioned, that you avoid 'boxing' and 'unboxing' and that your classes are type-safe.With Generics this is a lot easier. We have collections containing only strings, only integers, only your own custom class type. This, of course, makes it type-safe. We'll never try to cast a string to an integer ever again, because we know the collection contains only strings and not integers.Non-Generic collection which collection can hold the different type of data.Generic collection which collection can hold the same type of data.Generics involves type-safety.Most collection classes derive from the interfaces ICollection, IComparer, IEnumerable, IList, IDictionary, and IDictionaryEnumerator and their generic equivalents.
{
Generic<string> g = new Generic<string>();
g.Field = "A string";
//...
Console.WriteLine("Generic.Field = \"{0}\"", g.Field);
Console.WriteLine("Generic.Field.GetType() = {0}", g.Field.GetType().FullName);
Console.WriteLine();
Console.ReadKey();
}
public class Generic<T>
{
public T Field;
}
******************************
A collection is simply a collection of whatever. Object, strings, integers, Persons, all of the above...Collections can hold different data type. Here all the elements are objects. In generics, we can specify which datatype we want to store.That might still not be very simple. But basically a 'Generic' is a method to make something work with ANY type. The pro's to this are, as already mentioned, that you avoid 'boxing' and 'unboxing' and that your classes are type-safe.With Generics this is a lot easier. We have collections containing only strings, only integers, only your own custom class type. This, of course, makes it type-safe. We'll never try to cast a string to an integer ever again, because we know the collection contains only strings and not integers.Non-Generic collection which collection can hold the different type of data.Generic collection which collection can hold the same type of data.Generics involves type-safety.Most collection classes derive from the interfaces ICollection, IComparer, IEnumerable, IList, IDictionary, and IDictionaryEnumerator and their generic equivalents.
******************************************
3. What is the difference between generics and collections?
Generics provides the type safe code with re-usability like as algorithm. In algorithms such as sorting, searching, comparing etc. you don’t specify what data type(s) the algorithm operates on. The algorithm can be operates with any types of data. In the same way Generics operate, you can provide different data type to Generics. For example, a sorting algorithm can operates on integer type, decimal type, string type, DateTime type etc.
*****************
Code Re-usability with Generics
They simply complement each other, as Collections can exist without Generics and Generics can exist without Collections.
***********************
we have two type of collection:
****************************
With help of Generics you can avoid boxing and unboxing problems.
Generics provides the type safe code with re-usability like as algorithm. In algorithms such as sorting, searching, comparing etc. you don’t specify what data type(s) the algorithm operates on. The algorithm can be operates with any types of data. In the same way Generics operate, you can provide different data type to Generics. For example, a sorting algorithm can operates on integer type, decimal type, string type, DateTime type etc.
*****************
Code Re-usability with Generics
Suppose, you required to sort the integer and floating type numbers, then let's see how to do in collections and generics.
How to do it using Collections
//Overloaded sort methods
private int[] Sort(int[] inputArray)
{
//Sort array
//and return sorted array
return inputArray;
}
private float[] Sort(float[] inputArray)
{
//Sort array
//and return sorted array
return inputArray;
}
How to do it using Generics
private T[] Sort(T[] inputArray)
{
//Sort array
//and return sorted array
return inputArray;
}
*********************They simply complement each other, as Collections can exist without Generics and Generics can exist without Collections.
***********************
we have two type of collection:
****************************
With help of Generics you can avoid boxing and unboxing problems.
4. Can we use return keyword inside a finally block?
No.
you can not leave the body of finally clause like this.
No.
you can not leave the body of finally clause like this.
5. ----Reverse string program without using .net methods?
6. What is caching? And different type of caching?
6. What is caching? And different type of caching?
7. What is boxing and un-boxing? Give example.
Converting a value type to reference type is called Boxing.
Unboxing is the opposite operation and is an explicit operation.
.NET provides a unified type system. All types including value types derive from the type object. It is possible to call object methods on any value, even values of primitive types such as int.
class Test
{
static void Main() {
int i = 1;
object o = i; // boxing
int j = (int) o; // unboxing
}
}
it is ability to treat value types as objects bridges the gap between value types and reference types that exists in most languages
Converting a value type to reference type is called Boxing.
Unboxing is the opposite operation and is an explicit operation.
.NET provides a unified type system. All types including value types derive from the type object. It is possible to call object methods on any value, even values of primitive types such as int.
class Test
{
static void Main() {
int i = 1;
object o = i; // boxing
int j = (int) o; // unboxing
}
}
it is ability to treat value types as objects bridges the gap between value types and reference types that exists in most languages
8. What is the difference between ArrayList and Array?
9. What is indexer?
10. What is cluster and non-cluster index? How many non-cluster index a table can have?
1 Clustered Index + 999 Nonclustered Index = 1000 Index
1 Clustered Index + 999 Nonclustered Index = 1000 Index
No comments:
Post a Comment