Tips

C# Classes are reference types; they are allocated on the Managed Heap. The Managed Heap is an area of memory that is managed by the Common Language Runtime, which has the ability to free unused memory blocks (objects) in a process known as Garbage Collection.

Access Modifier keywords: public, private, protected and internal.

Class members: fields, properties, methods, constructors, destructor, indexers, constants, events, delegates and operators.

Struct: Similar to Class, A struct type is a value type that can contain constructors, constants, fields, methods, properties, indexers, operators, events, and nested types. By default it is sealed. There is no inheritance for structs as there is for classes. The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color.

class Program

{

struct Simple

{ public int Position;

public bool Exists;

public double LastValue;

};

static void Main ()

{

Simple s;

s.Position = 1;

s.Exists = false;

s.LastValue = 5.5;

}

}

Static class: a static class cannot be instantiated. In other words, you cannot use the new keyword to create a variable of the class type. Ex: UtilityClass.MethodA ();

* Contains only static members. * Cannot be instantiated. * Is sealed. * Cannot contain Instance Constructors.

Static member: A non-static class can contain static methods, fields, properties, or events. The static member is callable on a class even when no instance of the class has been created. The static member is always accessed by the class name, not the instance name. Only one copy of a static member exists, regardless of how many instances of the class are created. Static methods and properties cannot access non-static fields and events in their containing type, and they cannot access an instance variable of any object unless it is explicitly passed in a method parameter. We can’t use this keyword to access Static Members.

Abstract Class: –cannot be instantiated. – An abstract class is only to be sub-classedinherit only one abstract class, but may implement multiple numbers of Interfaces. – Abstract class methods may OR may not have an implementation. (inherited from). – A class may

An Interface contains only the signatures of methods, properties, events or indexers. A class or struct that implements the interface must implement the members of the interface that are specified in the interface definition.

Ex:

Interface ISampleInterface

{ Void SampleMethod (); }

Class ImplementationClass: ISampleInterface

{ // Explicit interface member implementation:

Void ISampleInterface.SampleMethod ()

{ // Method implementation. }

Static void Main ()

{ ISampleInterface obj = new ImplementationClass ();

Obj. SampleMethod (); }

}

Abstract and Virtual Method:

When a base class declares a method as virtual, a derived class can override the method with its own implementation.

If a base class declares a member as abstract, that method must be overridden in any non-abstract class that directly inherits from that class.

Sealed class: A sealed class cannot be used as a base class; it cannot also be an abstract class. By creating an instance we can use the methods in the Sealed Class.

Delegates: Delegates are used to pass methods as arguments to other methods. It allow programmer to encapsulate a reference to a method inside a delegate object.

public delegate void SimpleDeleg();

class DelegateExample

{

public void SimpMet()

{

string s= “I am From Simple Method.”;

}

public static void main()

{

SimpleDeleg del = new SimpleDeleg(SimpMet);

SimpleDeleg();

}

}

Value type variables directly contain their values, which mean that the memory is allocated inline in whatever context the variable is declared.

There are two categories of value types: struct and enum.

A type that is defined as a class, delegate, array, or interface is a Reference type. At run time, when you declare a variable of a reference type, the variable contains the value null until you explicitly create an instance of the object by using the new operator

A Generic type can be declared with one or more type parameters. Generic collection classes are called strongly-typed collections because the compiler knows the specific type of the collection’s elements and can raise an error at compile-time if, for example, you try to add an integer to the strings object.

Namespaces: .NET Framework uses namespaces to organize its many classes. Namespaces are used to logically arrange classes, structs, interfaces, enum and delegates. One namespace can contain other namespaces also.

The enum keyword is used to declare an enumeration (a numbered list), a distinct type consisting of a set of named constants called the enumerator list.

enum Days {low, medium, high};

class EnumSwitch

{

Public Static Void Main ()

{

Volume myVolume = Volume. Medium;

switch (myVolume)

{

case Volume. Low:

Console.WriteLine(“The volume has been turned Down.”);

break;

case Volume. Medium:

Console.WriteLine (“The volume is in the middle.”);

break;

Case Volume. High:

Console.WriteLine (“The volume has been turned up.”);

break;

}

Console.ReadLine ();

}

}

Dictionary: A Dictionary (TKey, TValue) contains a collection of key/value pairs. Its Add method takes two parameters, one for the key and one for the value.

Dictionary students = new Dictionary()

{

{111, new StudentName {FirstName=”Sachin”, LastName=”Karnik”, ID=211}},

{112, new StudentName {FirstName=”Dina”, LastName=”Salimzianova”, ID=317}},

{113, new StudentName {FirstName=”Andy”, LastName=”Ruth”, ID=198}}

};

Boxing: Conversion of Value Types to Reference Types.

Ex: int32 x=10;

Object obj=x; //Implicit Boxing; No need to tell the compiler about boxing

Object obj= (Object) x; //Explicit Boxing;

Unboxing: Conversion of Reference Types to Value Types.

X= obj; //Implicit Unboxing

Constructors: Constructors are class methods that are executed when an object of a given type is created. Constructors have the same name as the class. They do not have return types, not even void. Constructor is invoked by the new operator immediately after memory is allocated for the new object.

A constructor that takes no parameters is called a default constructor. Default constructors are invoked whenever an object is instantiated using the new operator and no arguments are provided to new.

Constructors for struct types are similar to class constructors, but structs cannot contain an explicit default constructor because one is provided automatically by the compiler.

Note: There is always at least one constructor in every class. If you do not write a constructor, C# automatically provides one for you, this is called default constructor.

Destructor: A destructor is just opposite to constructor. It has same as the class name, but with prefix ~ (tilde). They do not have return types, not even void and therefore they cannot return values. Destructor is invoked whenever an object is about to be garbage collected

Finalize () Method of Object class

Each class in C# is automatically (implicitly) inherited from the Object class which contains a method Finalize (). This method is guaranteed to be called when your object is garbage collected (removed from memory). You can override this method and put here code for freeing resources that you reserved when using the object.

Method Overloading: Method with same name but with different arguments is called method overloading. Method Overloading forms compile-time polymorphism.

Class A1

{

Void hello ()

{Console.WriteLine (“Hello”) ;}

Void hello (string s)

{Console.WriteLine (“Hello {0}”, s) ;}

}

Method Overriding: Method overriding occurs when child class declares a method that has the same type arguments as a method declared by one of its superclass. Method overriding forms Run-time polymorphism.

Note: By default functions are not virtual in C# and so you need to write “virtual” explicitly. While by default in Java each function are virtual.

Class parent

{ Virtual void hello ()

{ Console.WriteLine (“Hello from Parent”) ;}

}

Class child: parent

{ Override void hello ()

{ Console.WriteLine (“Hello from Child”) ;}

}

Static void main ()

{ Parent objParent = new child ();

objParent.hello ();

}

//Output

Hello from Child.

OOPS:

Polymorphism (Many Shapes): Polymorphism is briefly described as “one interface, many implementations. Polymorphism is a characteristic of being able to assign a different meaning or usage to something in different contexts.

There are two types of polymorphism one is compile time polymorphism and the other is run time polymorphism. Compile time polymorphism is functions and operators overloading. Runtime time polymorphism is done using inheritance and virtual functions.

Function Overloading: In case of compile time it is called function overloading. Two or more functions can have same name: different parameters or their data types. Compiler will select the right function depending on the type of parameters passed.

Operator Overloading: Operators can be overloaded in order to perform special functions with respect to the class. With the help of operator overloading standard operations such as +, – , *, etc can be applied on the objects of the class.

Encapsulation is the procedure of covering up of data and functions into a single unit. Ex: Delegate.

Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. Inheritance is the mechanism which allows a class A to inherit properties of a class B.

Note: A sealed class cannot be inherited. A sealed class is used primarily when the class contains static members. Note: Struct is implicitly sealed; so they cannot be inherited.

Inheritance and Polymorphism

Inheritance:

Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class.

Conceptually, a derived class is a specialization of the base class. For example, if you have a base class Animal, you might have one derived class that is named Mammal and another derived class that is named Reptile. A Mammal is an Animal, and a Reptile is an Animal, but each derived class represents different specializations of the base class.

  • When you define a class to derive from another class, the derived class implicitly gains all the members of the base class, except for its constructors and destructors.
  • The derived class can thereby reuse the code in the base class without having to re-implement it.
  • In the derived class, you can add more members. In this manner, the derived class extends the functionality of the base class.

C# supports two types of Inheritance mechanisms:

1) Implementation Inheritance
2) Interface Inheritance

Implementation Inheritance:

– When a class (type) is derived from another class(type) such that it inherits all the members of the base type it is Implementation Inheritance

Interface Inheritance:

– When a type (class or a struct) inherits only the signatures of the functions from another type it is Interface Inheritance

In general Classes can be derived from another class, hence support Implementation inheritance At the same time Classes can also be derived from one or more interfaces Hence they support Interface inheritance Structs can derive from one more interface, hence support Interface Inheritance Structs cannot be derivedfrom another class they are always derived from SystemValueType

Multiple Inheritance:

C# does not support multiple implementation inheritance A class cannot be derived from more than one class However, a class can be derived from Multiple Interfaces.

————————————

Inheritance Syntax:

Class derivedClass:baseClass
{
}

Interface Inheritance:

private Class derivedClass:baseClass , InterfaceX , InterfaceY
{
}

Abstract And Virtual Method:

When a base class declares a method as virtual, a derived class can override the method with its own implementation.

class baseClass
{
public virtual int fnCount()
{
return 10;
}
}

class derivedClass :baseClass
{
public override int fnCount()
{
return 100;
}
}

If a base class declares a member as abstract, that method must be overridden in any non-abstract class that directly inherits from that class.

If a derived class is itself abstract, then it inherit abstract members without implementing them.

Abstract and virtual members are the basis for polymorphism, which is the second primary characteristic of object-oriented programming.

Polymorphism:

Polymorphism is often referred to as the third pillar of object-oriented programming, after encapsulation and inheritance.

  • At run time, objects of a derived class may be treated as objects of a base class in places such as method parameters and collections or arrays. When this occurs, the object’s declared type is no longer identical to its run-time type.
  • Base classes may define and implement virtual methods, and derived classes can override them, which means they provide their own definition and implementation. At run-time, when client code calls the method, the CLR looks up the run-time type of the object, and invokes that override of the virtual method. Thus in your source code you can call a method on a base class, and cause a derived class’s version of the method to be executed.

Virtual methods enable you to work with groups of related objects in a uniform way.

For example, suppose you have a drawing application that enables a user to create various kinds of shapes on a drawing surface. You do not know at compile time which specific types of shapes the user will create. However, the application has to keep track of all the various types of shapes that are created, and it has to update them in response to user mouse actions. You can use polymorphism to solve this problem in two basic steps:

  • Create a class hierarchy in which each specific shape class derives from a common base class.
  • Use a virtual method to invoke the appropriate method on any derived class through a single call to the base class method.

Example:

public class Shape
{
// A few example members
public int X { get; private set; }
public int Y { get; private set; }
public int Height { get; set; }
public int Width { get; set; }

// Virtual method
public virtual void Draw()
{
Console.WriteLine("Performing base class drawing tasks");
}
}

class Circle : Shape
{
public override void Draw()
{
// Code to draw a circle...
Console.WriteLine("Drawing a circle");
base.Draw();
}
}
class Rectangle : Shape
{
public override void Draw()
{
// Code to draw a rectangle...
Console.WriteLine("Drawing a rectangle");
base.Draw();
}
}
class Triangle : Shape
{
public override void Draw()
{
// Code to draw a triangle...
Console.WriteLine("Drawing a triangle");
base.Draw();
}
}

class Program
{
static void Main(string[] args)
{
// Polymorphism at work #1: a Rectangle, Triangle and Circle
// can all be used whereever a Shape is expected. No cast is
// required because an implicit conversion exists from a derived
// class to its base class.
System.Collections.Generic.List shapes = new System.Collections.Generic.List();
shapes.Add(new Rectangle());
shapes.Add(new Triangle());
shapes.Add(new Circle());

// Polymorphism at work #2: the virtual method Draw is
// invoked on each of the derived classes, not the base class.
foreach (Shape s in shapes)
{
s.Draw();
}

// Keep the console open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}

}
-----------------------------------------

/* Output:
Drawing a rectangle
Performing base class drawing tasks
Drawing a triangle
Performing base class drawing tasks
Drawing a circle
Performing base class drawing tasks
*/

------------------------------------------

Source: MSDN & Exforsys

Class And Objects

Introduction:

In our world we have classes and objects for those classes. Everything in our world is considered to be an object. For example, people are objects, animals are objects too, minerals are objects; everything in the world is an object. Easy, right? But what about classes?

In our world we have to differentiate between objects that we are living with. So we must understand that there are classifications (this is how they get the name and the concepts of the Class) for all of those objects. For example, I’m an object, David is object too, Maria is another object. So we are from a people class (or type). I have a dog called Ricky so it’s an object. My friend’s dog, Doby, is also an object so they are from a Dogs class (or type).

A C# Class is considered to be the primary building block of the language.

We use classes as a template to put the properties and functionalities or behaviors in one building block for a group of objects and after that we use the template to create the objects we need.

The class: A building block that contains the properties and functionalities that describe some group of objects. We can create a class Person that contains:

1. The properties of any normal person on the earth like: hair color, age, height, weight, eye color.
2. The functionalities or behaviors of any normal person on the earth like: drink water, eat, go to the work.

There are 2 kinds of classes: The built-it classes that come with the .NET Framework, called Framework Class Library, and the programmer defined-classes which we create ourselves.

The class contains data (in the form of variables and properties) and behaviors (in the form of methods to process these data).

The object: It’s an object of some classification (or class, or type) and when you create the object you can specify the properties of that object. What I mean here is: I, as an object, can have different properties (hair color, age, height, weight) than you as another object. For example, I have brown eyes and you have green eyes. When I create 2 objects I will specify a brown color for my object’s eye color property and I will specify a green color for your object’s eye color property.

class Person
{
public int Age;
public string HairColor;
}

This is our simple class which contains 2 variables.

static void Main(string[] args)
{
Person Michael = new Person();
Person Mary = new Person();

// Specify some values for the instance variables
Michael.Age = 20;
Michael.HairColor = “Brown”;
Mary.Age = 25;
Mary.HairColor = “Black”;
// print the console’s screen some of the variable’s values
Console.WriteLine(“Michael’s age = {0}, and Mary’s age = {1}”,Michael.Age,
Mary.Age);
Console.ReadLine();
}

So we begin our Main method by creating 2 objects of type Person. After creating the 2 objects we initialize the instance variables for object Michael and then for object Mary. Finally we print some values to the console. Here, when you create the Michael object, the C# compiler allocates a memory location for the 2 instance variables to put the values there. Also, the same thing with the Mary object; the compiler will create 2 variables in memory for Mary object. So each object now contains different data.

Using Properties in Functions:

class Person
{
private int age;
private string hairColor;
public int Age
{
get
{
return age;
}
set
{
if(value = 18)
{
age = value;
}
else
age = 18;
}
}
public string HairColor
{
get
{
return hairColor;
}
set
{
hairColor = value;
}
}
}

I made some modifications, but focus on the new 2 properties that I created. So the property consists of 2 accessors. The get accessor, responsible of retrieving the variable value, and the set accessor, responsible of modifying the variable’s value. So the get accessor code is very simple. We just use the keyword return with the variable name to return its value. So the following code:

get
{
return hairColor;
}

returns the value stored in hairColor.

static void Main(string[] args)
{
Person Michael = new Person();
Person Mary = new Person();

// Specify some values for the instance variables
Michael.Age = 20;
Michael.HairColor = “Brown”;
Mary.Age = 25;
Mary.HairColor = “Black”;

// print the console’s screen some of the variable’s values
Console.WriteLine(“Michael’s age = {0}, and Mary’s age = {1}”,Michael.Age,
Mary.Age);
Console.ReadLine();
}

Here I created the same objects from the last example, except that I used only properties to access the variable instead of accessing it directly. Look at the following line of code

Michael.Age = 20;

When you assign a value to the property like that C# will use the set accessor. The great thing with the set accessor is that we can control the assigned value and test it; and maybe change to in some cases. When you assign a value to a property C# changes the value in a variable and you can access the variable’s value using the reserved keyword value exactly as I did in the example. Let’s see it again here.

set
{
if(value = 18)
{
age = value;
}
else
age = 18;
}

Here in the code I used if statement to test the assigned value because for some reason I want any object of type Person to be aged between 18 and 65. Here I test the value and if it is in the range then I will simply store it in the variable age. If it’s not in the range I will put 18 as a value to age.

We create a class by defining it using the keyword class followed by the class name:

class Person

Then we open a left brace “{” and write our methods and properties. We then close it with a right brace “}”. That’s how we create a class. Let’s see how we create an instance of that class.

In the same way as we declare a variable of type int we create an object variable of Person type with some modifications:

int age;
Person Michael = new Person();

In the first line of code we specified integer variable called age. In the second line we first specified the type of Object we need to create, followed by the object’s name, followed by a reserved operator called new. We end by typing the class name again followed by parentheses “()”.

Let’s understand it step-by-step. Specifying the class name at the beginning tells the C# Compiler to allocate a memory location for that type (the C# compiler knows all the variables and properties and methods of the class so it will allocate the right amount of memory). Then we followed the class name by our object variable name that we want it to go by. The rest of the code “= new Person();” calls the object’s constructor. We will talk about constructors later but for now understand that the constructor is a way to initialize your object’s variable while you are. For example, the Michael object we created in the last section can be written as following :

Person Michael = new Person(20, “Brown”);

Here I specified the variable’s values in the parameter list so I initialized the variables while creating the object.

Source: DevArticles

validation in ASP.Net

TITLE EXPRESSION DESCRIPTION MATCHES
NUMBERS ^[0-9]*$ only numbers are allowed 12345 | 12345678
CURRENCY ^\d+(?:\.\d{0,2})?$ Useful for checking currency amounts, such 5 or 5.00 or 5.25 1 | 1.23 | 1234.45
alpha numeric ^[a-zA-Z0-9]+$ it will check for alphanumeric (Alpha Numeric) values. adad1213 | 1231dfadfa | dfad123dfasdfs

ASCII Character Set

Character Entity Number Entity Name Description
" " " quotation mark
' ' (does not work in IE) apostrophe 
& & & ampersand
< < &lt; less-than
> > &gt; greater-than

ISO 8859-1 Symbols:

Character Entity Number Entity Name Description
    &nbsp; non-breaking space
¡ ¡ &iexcl; inverted exclamation mark
¢ ¢ &cent; cent
£ £ &pound; pound
¤ ¤ &curren; currency
¥ ¥ &yen; yen
¦ ¦ &brvbar; broken vertical bar
§ § &sect; section
¨ ¨ &uml; spacing diaeresis
© © &copy; copyright
ª ª &ordf; feminine ordinal indicator
« « &laquo; angle quotation mark (left)
¬ ¬ &not; negation
­ ­ &shy; soft hyphen
® ® &reg; registered trademark
¯ ¯ &macr; spacing macron
° ° &deg; degree
± ± &plusmn; plus-or-minus 
² ² &sup2; superscript 2
³ ³ &sup3; superscript 3
´ ´ &acute; spacing acute
µ µ &micro; micro
&para; paragraph
· · &middot; middle dot
¸ ¸ &cedil; spacing cedilla
¹ ¹ &sup1; superscript 1
º º &ordm; masculine ordinal indicator
» » &raquo; angle quotation mark (right)
¼ ¼ &frac14; fraction 1/4
½ ½ &frac12; fraction 1/2
¾ ¾ &frac34; fraction 3/4
¿ ¿ &iquest; inverted question mark
× × &times; multiplication
÷ ÷ &divide; division

ISO 8859-1 Characters:

Character Entity Number Entity Name Description
À À &Agrave; capital a, grave accent
Á Á &Aacute; capital a, acute accent
  &Acirc; capital a, circumflex accent
à à &Atilde; capital a, tilde
Ä Ä &Auml; capital a, umlaut mark
Å Å &Aring; capital a, ring
Æ Æ &AElig; capital ae
Ç Ç &Ccedil; capital c, cedilla
È È &Egrave; capital e, grave accent
É É &Eacute; capital e, acute accent
Ê Ê &Ecirc; capital e, circumflex accent
Ë Ë &Euml; capital e, umlaut mark
Ì Ì &Igrave; capital i, grave accent
Í Í &Iacute; capital i, acute accent
Î Î &Icirc; capital i, circumflex accent
Ï Ï &Iuml; capital i, umlaut mark
Ð Ð &ETH; capital eth, Icelandic
Ñ Ñ &Ntilde; capital n, tilde
Ò Ò &Ograve; capital o, grave accent
Ó Ó &Oacute; capital o, acute accent
Ô Ô &Ocirc; capital o, circumflex accent
Õ Õ &Otilde; capital o, tilde
Ö Ö &Ouml; capital o, umlaut mark
Ø Ø &Oslash; capital o, slash
Ù Ù &Ugrave; capital u, grave accent
Ú Ú &Uacute; capital u, acute accent
Û Û &Ucirc; capital u, circumflex accent
Ü Ü &Uuml; capital u, umlaut mark
Ý Ý &Yacute; capital y, acute accent
Þ Þ &THORN; capital THORN, Icelandic
ß ß &szlig; small sharp s, German
à à &agrave; small a, grave accent
á á &aacute; small a, acute accent
â â &acirc; small a, circumflex accent
ã ã &atilde; small a, tilde
ä ä &auml; small a, umlaut mark
å å &aring; small a, ring
æ æ &aelig; small ae
ç ç &ccedil; small c, cedilla
è è &egrave; small e, grave accent
é é &eacute; small e, acute accent
ê ê &ecirc; small e, circumflex accent
ë ë &euml; small e, umlaut mark
ì ì &igrave; small i, grave accent
í í &iacute; small i, acute accent
î î &icirc; small i, circumflex accent
ï ï &iuml; small i, umlaut mark
ð ð &eth; small eth, Icelandic
ñ ñ &ntilde; small n, tilde
ò ò &ograve; small o, grave accent
ó ó &oacute; small o, acute accent
ô ô &ocirc; small o, circumflex accent
õ õ &otilde; small o, tilde
ö ö &ouml; small o, umlaut mark
ø ø &oslash; small o, slash
ù ù &ugrave; small u, grave accent
ú ú &uacute; small u, acute accent
û û &ucirc; small u, circumflex accent
ü ü &uuml; small u, umlaut mark
ý ý &yacute; small y, acute accent
þ þ &thorn; small thorn, Icelandic
ÿ ÿ &yuml; small y, umlaut mark

All Country List in a Dropdownlist c#

using System.Collections.Generic;
using System.Globalization;

Page_Load

{
PopulateCountryName(ddl_country);
}


private void PopulateCountryName(DropDownList dropDown)
{
Hashtable h = new Hashtable();

Dictionary<string, string > objDic = new Dictionary<string, string >();

foreach (CultureInfo ObjCultureInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{

RegionInfo objRegionInfo = new RegionInfo(ObjCultureInfo.Name);

if (!objDic.ContainsKey(objRegionInfo.EnglishName))
{
objDic.Add(objRegionInfo.EnglishName, objRegionInfo.TwoLetterISORegionName.ToLower());
}
}
List<KeyValuePair<string, string>> myList = new List<KeyValuePair<string, string>>(objDic);
myList.Sort(

delegate(KeyValuePair<string, string> firstPair,

KeyValuePair<string, string> nextPair)
{
return firstPair.Value.CompareTo(nextPair.Value);
}
);
foreach (KeyValuePair<string, string> val in myList)
{
dropDown.Items.Add(new ListItem(val.Key, val.Value));
}
}

Working with Accordion Pane

Working with Accordion Pane

In Registry:


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<cc1:Accordion ID="Accordion1" runat="server" SelectedIndex="0" Width="100%"
HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected"
ContentCssClass="accordionContent" FadeTransitions="false" FramesPerSecond="40"
TransitionDuration="250" AutoSize="None" RequireOpenedPane="false"
SuppressHeaderPostbacks="true">
<Panes>

<cc1:AccordionPane ID="AC" runat="server">
<Header>
<asp:Label ID = "lbl_PersonelDetails" Text = "Course Details" Font-Bold="True"
Font-Names="Verdana" Font-Size="Small" runat = "server"></asp:Label>
</Header>
<Content>

<table class="TAB_INNER">
<tbody><tr> <td>
Content I
</td>
</tr>
</tbody></table>
</Content>
</cc1:AccordionPane>

<cc1:AccordionPane ID="AD" runat="server" Width="100%">
<Header>
<asp:Label ID = "Label2" Text = "Department Details" Font-Bold="True"
Font-Names="Verdana" Font-Size="Small" runat = "server"></asp:Label>
</Header>
<Content>
<table class="TAB_INNER">
<tbody><tr> <td>
Content I
</td>
</tr>
</tbody></table>

</Content>
</cc1:AccordionPane>

</Panes>

</cc1:Accordion>

MDI Parent WinForms c#

Close All Mdi Child forms in Mdi Parent C#

foreach (System.Windows.Forms.Form form1 in this.MdiChildren)
{
form1.Close();
}

SQL Server Questions only

Revisiting basic syntax of SQL?
What are “GRANT” and “REVOKE’ statements?
What is Cascade and Restrict in DROP table SQL?
What is a DDL, DML and DCL concept in RDBMS world?
What are different types of joins in SQL?
What is “CROSS JOIN”?
You want to select the first record in a given set of rows?
How do you sort in SQL?
How do you select unique rows using SQL?
Can you name some aggregate function is SQL Server?
What is the default “SORT” order for a SQL?
What is a self-join?
What’s the difference between DELETE and TRUNCATE ?
Select addresses which are between ‘1/1/2004’ and ‘1/4/2004’?
What are Wildcard operators in SQL Server?
What’s the difference between “UNION” and “UNION ALL” ?
What are cursors and what are the situations you will use them?
What are the steps to create a cursor?
What are the different Cursor Types?
What are “Global” and “Local” cursors?
What is “Group by” clause?
What is ROLLUP?
What is CUBE?
What is the difference between “HAVING” and “WHERE” clause?
What is “COMPUTE” clause in SQL?
What is “WITH TIES” clause in SQL?
What does “SET ROWCOUNT” syntax achieves?
What is a Sub-Query?
What is “Correlated Subqueries”?
What is “ALL” and “ANY” operator?
What is a “CASE” statement in SQL?
What does COLLATE Keyword in SQL signify?

Convert a file into bytes C#

private void GetOpenFileDialog()
{
openFileDialogX.CheckPathExists = true;
openFileDialogX.Filter = “Text files (*.text)|*.txt|doc files (*.doc)|*.doc|pdf files (*.pdf)|*.pdf|excel files(*.xls)|*.xls|excel files07(*.xlsx)|*.xlsx”;
openFileDialogX.Multiselect = false;
openFileDialogX.AddExtension = true;
openFileDialogX.ValidateNames = true;
openFileDialogX.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
openFileDialogX.ShowDialog();

Fname = openFileDialogX.FileName.ToString();
Fsize = openFileDialogX.FileName.Length;
Fext = System.IO.Path.GetExtension(Fname);

FileInfo fi= new FileInfo(Fname);
long numbyt= fi.Length;

FileStream FS = new FileStream(Fname, FileMode.Open, FileAccess.Read);
BinaryReader BR = new BinaryReader(FS);
filbyt = BR.ReadBytes(Convert.ToInt32(numbyt));

}

source: http://www.dotnetspider.com/projects/512-Store-Retrieve-pdf-txt-doc-Images-Sql-server-database.aspx