Professional Documents
Culture Documents
Stand alone:
- It is also known as single user apps
- Single user at a time will communicate with that application.
- For every user it is must to have a seperate installation.
- Console, Windows, Mobile etc.
Distributed:
- It is also known as Multi user apps
- Multiple users will communicate with the application at a single time.
- The application need to be installed in "Server" and can be accessed with the
help of "client".
- Web Application
What is .Net?
- .Net is a framework and also a runtime/execution time environment for all
the .Net applications.
Technology:
- It is limited to build a kind of application or used to do a perticular task.
Is .Net is a Technology?
It is not a technology, rather it is a collection of technologies
- ASP.Net, ASP.Net Core,ADO.Net, WPF,XAMARIN etc.
Tool:
- Which is used to speed up the development time, by provinding auto generation.
Is .Net is a Tool?
- No, it support different tools like IDE tool(Visual Studio and SSMS) and ORM
Tools(LINQ and EF).
Framework:
- It is a collection of things together to build the application.
- .Net is a framework, beacuse it is having collection of things like
- Programming languages
- Technologies
- Tools
- Applications
- Class Libraries (Asembly).
-----------------------------------------------------------------------------------
---------------------------
Compiler:
- Compiler is used to check the syntactical error.If there is no error it will
perform convertion.
- Compiler is used convert the program into machine understandable format.
Language Interoperability:
- The code that was developed in one PL can be consumed in another PL.
-----------------------------------------------------------------------------------
-----------
----------------
Components of .Net/ .Net Framework:
.Net => Framework + Runtime/Execution Environment
.Net => Class Librabries + CLR(Common Language Runtime)
Value Types:
- It will store value directly into the memory location.
- These are stored in Stack memory.
- Examples: int, double, float, char,structure,enum etc.
- Every value type is a structure.
- The process of converting value type to reference type is known as "boxing".
- CLR is not providing automatic memory management for value types(Stack memory)
Reference Type:
- It will store the address of the value.
- These variables are stored in stack memory and values in Heap memory.
- Examples: Array,String, Class, interface, delegates etc.
- Every reference type is a "Class".
- The process of converting reference type to value type is known as "unboxing".
- CLR is providing automatic memory management for the heap memory/Reference type
members.
-----------------------------------------------------------------------------------
--------------------------------------
Garbage Collector:
- It is component of CLR, which can be used to perform automatic memory management.
- Whenever we run the applications, internally it create the objects and all these
objects are store in the Heap memory.
- If the objects are completely filled we can't able to open/create a new
application.
- To overcome above situation GC will look into memory and identify two kinds of
objects like
- Objects that are in use
- Objects that are idealed
- Whenever it find idealed objects then immediatly it will kill those objects.
Class Librabries :
- It is a collection of classes.
- These class librabry is of two types
- User Defined
- User/Developer for projects.
- If it is user defined class library it should be under project
folder
- It is having file extensions of eigther *.dll or *.exe
- System Defined
- Microsoft for all the .Net applications.
- It is under GAC(Global Assembly Cache), the physical
location of GAC is "C:\Windows\assembly".
- These comes with a file extention "*.dll"(Dynemic Link
Librabry)
*.exe:
- It stands for Executable file.
- A class with Main() after build will create the EXE.
- These files are not reusable.
- It contains the code in the form of Binary/Native.
- These file will run/execute independently.
-----------------------------------------------------------------------------------
-----
S/W requirements for .Net:
- Visual Studio Community 2022
- Sql Server Management Studio(SSMS) - 2018 - IDE Tool
- Sql Server - DB Server
- Windows OS/Mac OS
Note: To build .Net application it's not mandatory to use Visual Studio, we can
build by using simple Notepad also.
Namespace:
- A Namespace is a collection of classes.
- It is a logical container of classes.
- A namespace which is used to avoid the naming collission between the classes.
- If we want to use Microsoft classes then that relevent namespace should be used
as "using" statement
- Suppose we want to create our own project then we can create a namespace by using
"namespace" keyword.
Note: Mostly namespace name and project name are similar, but it is not mandatory.
C#.Net:
- C#.Net is a pure Object Oriented Programming language.
- C#.Net is a case sensitive.
- C#.Net is a type(datatype) safe language.
- In C#.Net every program execution will start from Main().
- Every statement should end with a statement terminator(;).
- For every Open delemeter "{" there should be a closing delemeter "}".
-----------------------------------------------------------------------------------
-----
Console Apps I/O Statements:
- Console is a class, which is already avaible in a namespace i.e. "System".
- This class is having methods for I/O operations like
- Write();
- WriteLine();
- Read();
- ReadLine();
- Clear(); etc.
Write():
- This method is used to display some message to the user.
- After display the control remains in the same line, so that it will display next
statements also in the same line.
WriteLine():
- This method is used to display some message to the user.
- After display the control jumps to new line.
Read():
- It is used to take the input from the user.
- This function is used to read the single charecter from the user, even if user
has eneterd multiple charecters.
- It will not read the exact value, rather it will read ASCII value.
- The return type of this function is "int".
ReadLine():
- It is also used to take the input from the user.
- This function is used to read multiple charecters or single charecter also.
- It will read exact value, entered by the user.
- The return type of this function is "string".
ReadKey():
- Used to read a special charecters like Enter, Backspace etc.
Clear():
- It is similar to clrscr() in C/C++ langauge. It is used to clear the screen.
Note:
- A solution is a collection of projects, a project can be anything like Console,
Windows, Web etc
- A Project is a collection of Items, an item can be anything like Class,
Interface, WinForm, Web Form etc.
- Only for the identification the class name and file names are similar but it is
optonal, but it is good programming practice.
- Function and Methods both are similiar in syntax, Both are used to execute the
logic whenever we call.
- The difference between function and method is, function will have "datatype" as
the return type, method will have "void" as the return type.
- Function is return something so that we have to store in a variable, but method
will not return anything.
- A Variable is used to store the values, the variable is also called as named
memory location.
- Every variable is assosiated with a datatype, which is used to specify the type
of the data the variable can hold.
- A Comment will not compiled and executed by the compiler.
- Comments will give us an easy way to understand the code.
- In C#.Net we have three types of comments
- Single Line - //
- Multi Line - /* Statements */
- XML Comments - ///
-----------------------------------------------------------------------------------
--------------------------------------
Type Casting:
- Converting one type of data into another type based on the requirement.
- C#.Net supports two types
1) Implcit type casting: No need to have seperate methods to perform type casting.
2) Explicit type casting: We need to use seperate methods to perform type casting.
- C++ type casting: It can be used to convert value to value (or) reference to
reference type.
- Parse(): It used to convert only string datatype to anyother value datatype.
Beacuse Parse method is assosiated with only value types like int,double,float,
char etc.
- Convert class: It is a class which is avaible in System namespace, which contains
different methods, those are used to convert any datatype into any other datatype.
Convert.ToInt32()
Convert.ToDouble()
Convert.ToChar()
Convert.ToBoolean() etc.
Note:
- The process of converting value type to reference type is called "Boxing".
- The process of converting reference type to value type is called "Unboxing".
-----------------------------------------------------------------------------------
-----
Steps to write the code in Notepad and Execute:
- Open Notepad and write the program.
- Save with an extension i.e. "*.cs"(C#)
- Open the Developer Command Prompt for Visual Studio 2022.
- Change the Directory to where file was existed.
- Compile the cs file by using a command "csc Filename.cs", It wil generate exe
file if we don't have errors.
- Execute by using "filename.exe".
Conditional Statements:
- The statments which can be executed based on conditions.
- Like every PL, C#.Net is also having all types of conditional statements like
- Simple If: If condition true, then execute
- If Else: If the condition is true then execute a block else execute another
block of statments
- Nested If else: An If else condition within another if else.
- If else Ladder: An if else condition followed by another if else
- Switch case: It is for writing more conditions by using cases.
switch(args)
{
case 0:
break;
:
:
:
defualt:
break;
}
Assignments:
- Fabonacci Series Program
- Palindrome Program
- Reverse given number
- Arm Strong Number
- Prime Number
above examples complete by using for and while loop?
-----------------------------------------------------------------------------------
-----
Arrays:
- An array is a variable which is used to store multiple values into it.
- An Array is a reference type.So that the values are stored in the heap memory.
- To represent an array we use "[]".
- An array wil store the data in key and value, where key is an index and it strat
from 0, value is depend on the type of array.
- Array is a type safe variable.
- The one disadvantage with arrays is "Fixed Length".
- In C#.Net we have 3 arrays
- Single Dimentional: Eigther single row or single column
- Multi Dimentional: Eigther multiple rows and column of equal or different
sizes also.
- Jagged Arrays: Every element is an array, with different size
- Jagged Array is also known as Arrays of Array which means every element in Jagged
Array is a Array only.
- To create a Jagged Array we will use [][].
Assignment:
- Single Dimentional: Copy the elements of array which is greater than 50.
- Multi Dimentional: Create a 2D array with dynemic data
- Jagged Array: Create Jagged array with the elements of 2D Array
Enums in C#.Net:
- It is a variable which contain named constants.
- It is not a class member so that we can declare it inside namespace directly.
- The advantage of declaring inside the namespace is, it can be available through
out the project in any class.
-----------------------------------------------------------------------------------
-----
- Before OOPS we use procedure oriented programming which means we can write
everything in functions/procedure. The limitations of procedure programming is
Reusability and security.
- C#.Net is a Pure Object Oriented Programming Language.
OOPS: Every PL if it is an OOPS, it must follow 4 features
- Encapsulation: Binding the member variables along with member functions, best
example for encapsulation is "class".
- Abstraction: Hiding the implmentation, providing the service.
In C#.Net, abstraction can be implemented in two ways
- Data Abstrction
- Functional Abstraction
Class:
- A class is a collection of data members and member function.
- A class is a user defined datatype and object is a variable of class type.
- Inside the we can define 7 types of members
Data Members
- Variables
- Properties
- Indexers
Member Functions
- Methods/Functions
- Constructors
- Destructors
- Events
- A class is a logical entity, which contain similar type of members.
- Syntax:
class <className>
{
//members
//functions/methods
}
Object:
- An object is a physical existence. It is an instance of the class.
- syntax:
<className> <ObjName> = new <className>();
- "new" keyword is used to allocate the memory for the class and it's members.
Variable: It is a named memory location, which can be used to store the values.
- Only variables can store the data and no other member will not store data
anywhere.
- syntax: datatype varibleName = value;
- example: int x = 10;
Method/Fuction:
- Both are used to execute the logic, which can be used for reusability.
- Syntactically both function/method are similar.
<accessModifier> <returnType> <NameOfFun>([Optional parameters])
{
//Statements;
}
- But while implmentation, if the return type is void that is method, if the return
type is datatype i.e function.
- Method can't retutn anything it just used to execute the logic, but function will
return something to the calling place.
-----------------------------------------------------------------------------------
-----
Constructor:
- It is also similar to the function, but constructor is specially designed to
intilize the values for the class members.
- The constructor will be called automatically when an object to the class is
created.
- To create a constructor will follow two rules
- Constructor name should similar to class name
- Constructor doen't have return type including void also.
- A class can have any number of constructors but it should be overloaded.
- In C#.Net we have two categories of constructors
- Instance Constructors
- Default Constructor
- User-Defined Defualt Constructor
- System-Defined Defualt Constructor
- Parameterized Constructor
- Copy Constructor
- Private Constructor
- Static Constructors
- Static Constructor
Default Constructor:
- A constructor which will be created without parameters. If user has created it
then that is called "User-Defined Default Constructor".
- In a class if we are not having any constructor then system will create it's own
and intilize the default values.
- In that case if it is a value type it will assign "0" else it will assign "null".
- The limitation is for every instance it will maintain similar data.
Parameterized Constructor:
- A constructor with parameter is called as Parameterized constructor.
- We can maintain different values for every instance of the class.
Note:
- A class can have more than one constructor, but it should be different eighter in
number of parameters or in type of parameters.
- "this" keyword is also known as current class instance. which is used to access
the members of current class.
Copy Constructor:
- It is used to copy one complete object data into another.
- In Copy constructor, we have class name as the parameter.
Private Constructor:
- A constructor which will be created by using private access modifier.
- If a class is having private constructor we can't able to create an object
outside of the class.
- Private constructor is used to maintain secured information, and which is used to
set the restriction to the class that we can't create an instance of it outside.
Note: Above all the constructors are the instance constructors, which means for
every instance it will create a seperate memory.
Static Constructor:
- It will not create seperate memory for every object.
- Static members are created with the help of static keyword, And also if we define
any member in static function i.e. also a static member.
- Normal members can be accessed with the help of "Object name", if it is a static
member can be accessed with "class name".
- For the static members memory allocation is done first, but if it is an instance
member memory allocated only after creating an object.
- A constructor which will be created with a static modifier. It used to intilize
static members.
- A static constructor must be a parameter less.
- It can't have access modifier also including "public".
- We can execute static constructor only once i.e first execution of class.
- A class can have only one static constructor.
Note: In a class if we have Main() and static constructor, first static constructor
will gets executed later Main() will be called.
Destructor:
- It is used to deallocate the memory.
- To create it we use "~".
- We can have only one, it will called based on number of objects inside the class.
- In class if we have a destructor we don't have control on objects disposing.
- It would be called after the complete application execution completes.
- It must be parameter less.
-----------------------------------------------------------------------------------
-----
Inheritence:
- It is the process of aquiring properties of one class into another class.
- It is the proces of creating a new class from already existing class.
- Advantage of inheritence is "Reusability".
- In inheritence,the derived class object will have complete control on base class,
but base class is not having any control on derived class.
- The class which give code is called as "Base/Parent/Super" class, the class which
takes/aquire the properties is called "Derived/Child/Sub" class.
- Single Inheritence: If we have single base classes
- Single Inheritence: Creating single Base + Single Derived
- Multilevel: Creating different levels of inheritecnce
- Heirarichal: creating multiple child classes from single base
- Multiple Inheritence: If we have multiple base classes
- Multiple Inheritence
- Hybrid inheritence
- Multiple inheritence is not possible with the help of classes, i.e. where we use
"Interface".
- If both base classes are having same function with same signature, while calling
that with the help of derived class object the compiler will get confused. This
situation is called "Ambiguity" situation of a compiler.
Polymorphism: One to many behaviours, Poly means many and morphism means
behaviours.
- It is a rule that the class should follow while creating the functions/methods.
- Static/Compile/Early binding polymorphism
- To achive static polymorphism we use "Method Overloading"
- Dynemic/Runtime/Late binding polymorphism
- To achive dynemic polymorphism we use "Method Hiding" and
"Method Overriding".
Method Overloading:
- Creating same function with different signature.
- A signature of a function includes number of parameters and type of parameters,
but method signature doesn't include return type.
- While calling the function at compile time itself we should come to know which
function will gets executed, i.e. reason we call it as "Static/Compile/Early
Binding polymorphism".
- It can be implmented in both base and derived classes.
Method Overriding:
- Creating same function with same signature in both base and derived classes.
- To work with method over riding we use "virtual" and "override" keywords.
- "virtual" can be given for base class members and "override" can be given for
"derived" class members.
- It is not mandatory to override a virtual function always and it is optional.
- If a function is not a virtual, we can't override it.
Method Hiding:
- Creating same function with same signature in both base and derived classes.
- In Method hiding we use "new" keyword for "Derived" class members.
- If the overriding of the base class member is mandatory, then we use Method
Hiding.
-----------------------------------------------------------------------------------
----
Abstract classes and Methods:
- A method which is not having any implmentation is called "abstract method".
- In a class if we have atleast one abstract method mark that class as "abstract
class".
- To create an abstract class or method we use "abstract" keyword.
- An abstract class can have both abstract and non abstract members.
- we can't able to instantiate an abstarct classes.
- It is mandatory to inherit a class from an abstarct class inorder to consume.
- Once we inherit it is must provide implmentation for base class abstract
members.
- While providing the implmentation for "abstarct function" in derived class we use
"override" keyword.
- Abstract classes can't used to implement multiple inheritence.
- Syntax:
<accessmodifier> <return type> <nameOfProperty>
{
set{variable = value;}
get {return variable;}
}
-Example:
public int PEmpID
{
//Used to assign data to the fileds
set
{
if (EmpID == 0)
EmpID = 101;
else
EmpID = value;
}
//Used to retrive the data from the fileds
get
{
return EmpID;
}
}
- A property will never store the data, it just used to transfer the data.
- In C#.Net we have 3 types of properties
- Read only : which contains only get accessor
- Write Only: Which contains only set accessor
- Read Write : Which contains both set & get accessor
Structures Vs Classes:
- Structure is the light version of classes
Structures
- It is a value type.
- It can't have defualt constructor.
- "new" keyword is not required.
- Inheritecne is not possible.
- A Structure can't be an abstract type.
Classes
- It is reference type.
- It can have any type of constructors.
- It is required to have a new keyword.
- It can be inherited.
- A Class can be an abstract type.
Partial Classes:
- It is used to provide the flexibility to the devloper to share the work.
- A class for which we have an implementation in multiple files.
- To create a partial class we use "partial" keyword.
What is the use of partial methods?
What is the difference between sealed classes and abstract classes?
-----------------------------------------------------------------------------------
-----
Exception Handling:
- Error:Compilation Error, It can be identify by the compiler and gives an
appropriate message to the developer, so that developer will fix it.
- If developer is not follow proper syntax will get these type of errors.
- Exception: Runtime Error, It can be identified by Exception Handling machanism.
- When we have an exception in the application then the application can cause
abnormal termination.
- Bug: Can be identified at testing environment and identified by testers.
Exception Handling:
- In C#.Net we have two ways to handle the exception.
- Logical Exception Handling: can be handled by using conditions.Always as C#.Net
developer give the first priority for this.If we are not able to handle exceptions
using logical then go with try catch.
- try catch implementation:
Syntax:
try
{
//Statements where there is a possibility of getting exceptions.
//It will execute only one time.
}
catch
{
//It is used to catch the exception and give proper message.
//We can have any number of catch blocks
}
finally
{
//Suppose if we have execption or not, if we want to execute a block of code
then will use this block, and it is optional to have and also we have only one
finally block.
}
Custom Exception:
- If the exception classes are not meet our requirement then wil create our own
exception class to display message to the user.
*.dll
- A class which is not having Main() after build it will generate dll file.
- Can't run itself need to attach any of the executable file.
- Can be reused for multiple projects
- It contains the code in MSIL(Microsoft Intermediate Language).
Types of assembly:
- C#.Net is having two librabries
Private Assembly: It will maintain a seperate copy for every project.
Public/Shared Assembly: The assembly which is avaible in GAC folder is called
public/shared assembly, it will not maintain a seperate copy of dll in the project
folder.
- To convert a private assembly into public will follow few steps
- Generate the Strong Name Key
sn -k Arthematic.snk
- Register Strong Name key
[assembly: AssemblyKeyFile("D:\\C#6AM\ \ConsoleAppExamples\\
CLibArthematic\\bin\\Debug")]
- Install the librabry by using GAC Utility
gacutil -i CLibArthematic.dll
-----------------------------------------------------------------------------------
-----
Generics:
- These are general datatypes, which means we can create our own datatypes.
- These are introduces in C# 2.0v
- We can apply the generics concept for
- Functions
- Classes
- Interfaces
- Delegates etc.
- The main advatage is type safety. And also it can be used to avoid creating
multiple function while overloading.
- To work with Generics we know two things
- Place holder represented by "<>"
- Type parameter.
Note: Always type parameter should be enclosed within the place holder.
Var vs Dynemic:
var:
- It was introduced with C# 3.0v
- It is an implicit typed variable, means datatype can be decided at compile time.
- Once we assign the value, we can't change the type.
- These member must to intilized.
- It can be used as local member, but it can't be used as global/parameters.
dynemic:
- It was introduced with C# 4.0v.
- Here type can be decided at runtime.
- We can chnage the value.
- Intilization is optional.
- It can be used as eigher local/global/paramter.
-----------------------------------------------------------------------------------
-----
Delegates:
- It is a function pointer, which can used to execute the functions.
- These are mainly used in "Event Driven Programming".
- Delegates are much more used in Winforms and ASP.Net Web forms development.
- Delegate is not a class member, eigther it can be created inside class or outside
the class.
- To work with deleate we follow 3 steps
- Create a delegate
- Instantiate a delegate
- Invoke a delegate
- There are two types of delegate
- Single Cast Delegate: Which is pointing single function.
- Multicast Delegate: Which is pointing multiple functions.
Note:
- While working with multicast delegate every fucntion should contain same
signature and also same return type i.e. "void".
- To add reference of a function we use "+=" and remove the reference we use "-=".
Generic Delegates:
- Func<>: It is used to execute "functions"(return type as datatype)
- Action<>: It is used to exeute "methods"(return type as void)
- Predicate<>: It is used to execute functions whose return type is "boolean".
-----------------------------------------------------------------------------------
-----
Collections:
- In C#.Net collections are the classes.
- These classes are used to store the unlimted values into a single
object/variable.
- Every collection internally runs with an algorithm, but as an OOPS no need to
learn algorithm becuase all the collections in C#.Net are the classes.
- All these collections are avaible in a namespace
- Normal Collections - System.Collections;
- Stack: LIFO
- Queue: FIFO
- ArrayList
- HashTable etc.
- Generic Collections - System.Collections.Generic;
- Stack<>
- Queue<>
- List<>
- Dictionaries<> etc.
Limitation Advantage
Arrays - Fixed in size Type safety
Collections - No type safe Dynemic resizing
Generic collection - - Type Safe + Dynemic
Note: For most of the .Net applications Visual Studio will be generate presentation
layer code automatically.
- Windows forms appliaction is a GUI based application, which can also be called as
desktop applications.
- A winforms application will contain collections forms, here form is container
control which can contain multiple controls within it.
- A form is also a control and every control in winform is a class. All the classes
are assosiated in a namespace i.e. "System.Windows.Forms".
Note: In Winforms by default the designer code will be generated automatically.
- User defined form class is inherited from system defined "Form".
Event:
- An event is nothing but an action performed by user.
- In .Net Winforms, Web forms and mobile apps are works based on "Event Driven
Programming".
- Event will generate a function is called "Event Handler Method" and that function
will get executed with Delegate(EventHandler).
- In winforms every control is by default assosiated with one event, and this event
is fired when user double click on the control.
Note:
While giving the name property of the control we should follow naming convetion by
using Hungarian Notation, according to that
Button - btn
Label - lbl
TextBox - txt
RadionButton - rbtn
CheckBox - chk
DataGridView - dgv
ComboBox - cmb etc.
-----------------------------------------------------------------------------------
-----
Controls in Winforms:
- TextBox: Used to take the input
- Button: Execute the logic
- Label: Used to display static text
Validation-3: When user click on Div button need to identify second number can't be
zero.
Validation-4: If user wants to reenter the data in the textbox and by clicking on
Backspace we have to handle it(Enable backspace button).
-----------------------------------------------------------------------------------
-----
GroupBox:
- It is having Text property
- It is not having scrolling facility
- It is occupying more design space.
Panel:
- We don't have Text property
- It comes with scrolling facility.
- It is not occupying more design space.
-----------------------------------------------------------------------------------
-----
- Collection Controls: Which are used to store multiple values
- ListBox
- DropdownList/ComboBox
- CheckBoxList etc
Dailouge Controls:
- These controls are used to display dailogue boxes like
- Save Dailouge
- Font Dailogue
- Color etc.
-----------------------------------------------------------------------------------
-----
ADO.Net:
- It is a middle ware technology which is used to interact with frontend and
backend applications.
- ADO.Net will be used to communicate with different datasources.
- To communicate like that ADO.Net is having different data providers like
- Sql Client -> Sql Server Database - Microsoft
- Oracle Client -> Oracle Server Database - Microsoft
- ODBC Client -> Any DB - Third Party
- OLEDB Client -> Any DB - Third Party
- Borland Client -> Any DB - Third Party
ADO.Net Objects:
- Connection Object
- Command Object
- DataReader Object
- DataAdapeter Object etc.
Stored Procedure:
- It is a set of pre compiled sql statements.
- All the stored procedure will be written in backend application only.
- It is not possible to perform Sql Injuction attacks.
Syntax:
create procedure <nameOfProc> [Parameter]
as begin
....Sql Statements...
end
Exec <nameOfProc>
Examples:
Select SP:
create procedure SelectEmps
as begin
select * from Employee
end
SelectEmps
Insert SP:
create procedure InsertEmp @Eno int,@Ename varchar(max),@Salary money,@Job
varchar(max),@Dname varchar(max)
as begin
insert into Employee values(@Eno,@Ename,@Salary,@Job,@Dname)
end
InsertEmp 106,'Srikanth',58745,'Trainer','Competency'
Delete SP:
create procedure DeleteEmp @Eno int
as begin
delete from Employee where Eno=@Eno
end
DeleteEmp 102
UpdateSP:
create procedure UpdateEmp @Eno int,@Ename varchar(max),@Salary money,@Job
varchar(max),@Dname varchar(max)
as begin
update Employee set Ename=@Ename,Salary=@Salary,Job=@Job,Dname=@Dname where
Eno=@Eno
end
UpdateEmp 106,'Cherry',58795,'Developer','IT'
-- Declare a Variable of Type Int. Should match with SP's Output parameter
DECLARE @Salary money
What is DataSet?
- It is an in memory object which can be used to represent the data in frontend
application
- It can be working with Disconnected model.
Architecture of DataSet:
- DataSet
- Tables
- Table1
- Rows
- Row1
- Row2
- Columns
- Col1
- Col2
- Table2
DataGridView Control:
- This control provides powerful and flexible way to display the data in a tabular
format.
-----------------------------------------------------------------------------------
-----
Extension Methods in C#.Net:
- These are the methods which can be added to the existing classes/structures
without midifying/compiling the source class.
- To create an extention method we use static classes and method we can define as
an extension method should be a static methods.
Nullable types:
- These are data types, especially value types which can be handle null values.
- To create this we use "?" for any valid value types.
Reflection:
- It is the process of identifying metadata of a class or structure.
- To work with this we use a class i.e. "Type".
Serialization:
- It is process of converting objects into streams, so that the data will be stored
into memory, file or DB. The reverse process of serialization is deserialization.
-----------------------------------------------------------------------------------
-----
ADO.Net Limitations:
- Developer has to learn all the query languages based to the Datasource.
- Queries are combination of Sql + OOPS.
- ADO.Net quries are not type safe.
- It doen't provide intellisence.
- It doesn't give error, rather it gives exceptions.
LINQ:
- It stands for Language Integrated Query.
- It contain uniform syntax, which can be used to communicate with any type of
datasource.
- It means even if the data source is changed no need to change query language.
- And also LINQ can be written in pure OOPS.
- Based on data source LINQ can be defined in following ways
- LINQ to Objects
- LINQ to SQL
- LINQ to Entity
- LINQ to ADO.Net DataSet
- LINQ to XML etc.
Note: LINQ quries are executed internally with the help of "ADO.Net Disconnected
Approch".
syntax:
var Obj = from <aliasName> in <collection> [clauese] select <aliasName>;
Example:
var Obj = from x in Emps select x;
LINQ to Object: It can be used to communicate with Objects like Arrays, Collections
etc.
-----------------------------------------------------------------------------------
-----
Advanced and New C#.Net 8.0 Concepts:
Ref and Out
- Both are used to return multiple values to the calling place.
- But if it is ref, even if we are not having implmentation at the time calling
what ever the values we intilized those are going to be used and intilizing those
values are mandatory.
- But if it is out, it is must to provide values at the time of implementation and
at the time of calling it is optional to define them even.
Tuple:
It is used to return multiple statetes to the calling place without using ref and
out keywords.
Deconstructors:
It is used to provide the access for the private field that can be accessed outside
of the class.
--------------***********------------------