2. Language Basics (5hrs)
  1. Variable and Data Types
  2. String & String Builder
  3. Boxing and Unboxing
  4. Operators
  5. Control Statements
  6. Arrays and Strings
  7. Procedures and Functions
2. Language Basics (5hrs)
  1. Variable and Data Types
  2. String and StringBuilder
  3. Boxing and Unboxing
  4. Operators
    • Arithmetic Operators
    • Relational Operators
    • Logical Operators
    • Bitwise Operators
    • Assignment Operators
    • Ternary or Conditional Operators
  5. Control Statement in C#
    • Loops constructs
    • Decision making statement
    • Other type of Control statement
  6. Arrays and Strings in C#
  7. Stored Procedure & Function
  1. Discuss Boxing and Unboxing in detail. [4] ********
  2. Short notes on String and String Builder. [2.5] ********
  3. Why do we use String Builder in place of string in C#.NET?[5]
  4. Differentiate value type and reference type in C# (ByVal and ByRef).[4] *
  5. Short notes on: Procedure & Function.[2.5]**
  6. Explain different types of Loops with an example using VB.NET. [4]
Variable
Variable refers to the value that can be changed during program execution. Variables are the name given to the location in the memory of the computer.
int a = 10;
where a is variable

Data Types
Data Types are the keywords that determine the characteristics of variable. Data types in a programming languages describes that what type of data a variable can hold.
int a;
int: is the data type
a: is the variable name

Data types in C# is mainly divided into three categories
  • Value Data Types
  • Reference Data Types
  • Pointer Data Types
Value Data Types Reference Data Types
Values of the variable are stored in the memory location. Memory address are stored as a reference in the memory.
Primitive data type like char,int,float,double are value type . Non-primitive data type like object, string .
Value type are arrange in stack Reference type are arrange in heap
They are derived from the class System.ValueType . They are derived from the class System.Object .

String StringBuilder
- String is immutable object which means once created cannot be changed. - StringBuilder is mutable object which means once created, can be changed.
- Any operation like insert, replace or append will perform on the new memory location. - Any operation like insert, replace or append will perform on the same memory location.
- Performance wise string is slow. - Performance wise it is high.
- In string we don’t have append keyword. - In StringBuilder we have append keyword.
- String belongs to system namespace. - It belongs to System.Text namespace.
- String is thread safe, which means string cannot be used by two threads simultaneously. - StringBuilder is not thread safe means it allows two threads to simultaneously access the same method.
- Example
static void main()
{
String s = "Hello";
s = s + " World"
Console.WriteLine(s);
}
- Example
static void main()
{
StringBuilder sb = new StringBuilder("Hello");
sb.Append("World");
Console.WriteLine(sb);
}
- Example
static void main()
{
String str = "";
      for(int i=1; i<5; i++)
      {
      str = str + i.ToString();
      }
}
- Example
static void main()
{
StringBuilder sb = "";
      for(int i=1; i<5; i++)
      {
      sb.Append(i.ToString());
      }
}

Boxing Unboxing
- Converting a value type (char, int, float, bool etc) into reference type (object) is called Boxing. - Converting a Reference type (object) into value type is called unboxing.
- In boxing, the value stored on the stack is copied to the object stored on heap memory. - In unboxing process, object's value stored on the heap is copied to value stored on stack.
- Boxing is implicit conversion. - Unboxing is explicit conversion.
- Example
int i = 24;
object ob = i; //boxing
- Example
int j = (int)ob; //unboxing

Both the boxing and unboxing consume more time and memory, and they are computationally expensive. They also lack in type safety and increases runtime overhead. It is always advised to avoid too much use of boxing and unboxing in the program.


Operators
An operators is a symbol that tells the compiler to perform certain mathematical and logical manipulations. And the data item or value on which operator perform the certain operation is called operand.




Control Statement in C#
The control statement are used to create special program features such as logical test, loops and branches. Control statement are used for repeated execution of certain sections of program for a fixed number of time.



Arrays and Strings
C# arrays are zero indexd, i.e, the array indexes start at zero. Arrays in C# work similarly to how arrays work in most of the other popular languages. There are however few differences that you should be aware of.

While declaring an array, the square bracket [ ] must come after the type, not the identifer.





Stored Procedure & Function
  1. Stored procedure is a group of sql statement that has been created once and stored in server database.
    A function is used for doing calculation instead of doing query.
  2. Procedures allows select as well as (INSERT/UPDATE/DELETE) statements in it whereas function allows only select statement in it.
  3. Stored procedures may or may not return values.
    - Select query will return value.
    - Insert, update & delete will not return value.
    But function should return value.
  4. Procedures can have input, output parameters for it whereas functions can have only input parameters.
  5. Functions can be called from procedure whereas procedures cannot be called from function.
  6. Exeption can be handled by try-catch block in a procedure whereas try-catch block cannot be used in function.
  7. We can go for transaction management in procedure whereras it is not possible in fuction.

Data Types in C#

String and StringBuilder

Boxing and Unboxing

Web hosting by Somee.com