NagaRaj Sri Sai Ram .Net -->C#
NagaRaj Sri Sai Ram .Net -->C#
C# Class Note Book (Bangar Raju)Dt:04-02-2010COBOL-Business
ApplicationPascal-Scientific ApplicationFort on-Mathematic
Application C Language is a generic language.Drawback:-Reusability
(Size of programming will be to be increase), Security(C Not
Secured). In Object oriented programming languages will available
Reusability, Security.Ex: - C++ In 90s New Problem will be
acquired, that is flat-form dependency (Developed On one Language),
Internet cable Exiting. Windows will not be secured, because its a
flat-form dependency. Yahoo Messenger is working LINUX Windows.
Google also working LINUX Windows. Java is a flat-form
independency. Visual Basic Microsoft its going to be a user
friendly language. There is a use in UPPER Case Key board letters,
LOWER Case Key board letters restrictions. Repaid application will
be fast. VB - Worked in only windows. SMC Simple Manage C (Same as
JAVA) Introduction:- .NET is a collection of languages Ex: - 20
languages minimum. COBOL is dependent on .Net. COBOL & Java is
Complete different. COBOL & .NET Machining too, Style is same.
SMC nothing but C#. C# is Case Sensitive. C, C++, Java object
oriented programs, Reusability. C, C++, Java Reusable only with in
Language. .Net Reusability all 20 Languages.Ex:-C# used In VB,
COBOL, and J #. Language intractability. Do you learning .Net your
are good application developer. But not good programmer. Do you
learning Java your are good Programmer. But not good Application
developer.
*** END OF THE DAY ***
Dt: 05-02-2010Flat-form Dependency:- Machine code is prepared to
Operating System. Source code Compiled Machine code (or) Native
code (exe) Machine code Pro: - compile windows machine code prepaid
OS. Windows Machine: - What is meant by flat-form dependency? In
this approach the source code when complied generates machine code
(or) native code (or) executive code. The problem with machine code
is if was generated an Operating System. It can be executed only
within the Operating System. Because its get proposed according to
the Operating System.
In the above case as the machine code (exe) is generated to
execute on windows the other operating system will not be capable
to run the code. So it is run on windows but not on UNIX.Flat-form
Independency:-Java:- Source CodeCompiled Byte code JVM Machine
Code. Byte code: - This cant understand any Operating System. JVM
run the code. The JVM is a byte code, its a Target code, JVM is not
a Independent, its depended. Window will be use window JVM;UNIX
will be use Unix JVM. What is the mean by flat-form independent? In
the approach the source code when compiled gets converted into
intermediate code (seemly finished). This intermediate code can be
carried and executed on. Provided software which is required to
convert the intermediate code into machine code was installed. In
turns of java byte code was the intermediate code which can be
executed on any machine provided JVM was install on it. This will
be taken the responsibility of convinced byte code according to the
Operating System. In this case JVM (Java Virtual Machine) is
converting the byte code in to Machine code specific the Operation
System. JVM on dependent on the Operating System.Java:-Source
Compiled Byte code Byte code JVM (Win) Windows Machine Code Byte
code JVM (UNIX) Unix Machine Code Byte code JVM (MAC) Windows
Machine Code.NET Languages:- CIL -- Common Intermediate Language
Code. CLR -- Common Language Runtime. VES -- Vertical Execution
System. Theflat-form independency provided under .Net language is
similar to that of java. Where the byte code knows called as CIL
Code. CIL is production name is MSIL Code (Micro Soft Intermediate
Language Code). This IL Code can be carry is executed provided the
CLR (Same as JVM).
*** END OF THE DAY ***
Dt: 06-02-2010
All Compilers will be generating in same CIL code. Compilation
and execution process in case of .Net languages take place as
follows:
All the .Net languages required a specific languages compiler
for complication of the program. But every language after
compilation ha to generate the same type of code that is CIL. It is
taken by the CIR to convert into machine code. As all language over
generating the same IL code. Code generated by one language can be
consumed from the other languages providing our intractability
language. It is called as language independency..NET:-- It was a
system which can be used in the development of various kind of
application like,1).Desktop (CUI, GUI)2).Web.3).Mobile CUICharacter
user interface. GUIGraphical user interface. LanguagesC#, VB.Net..
TechnologiesASP.Net, ADO.Net.... ServersWeb Server, Data Base
Server Under.Net we came a craze overuse thing like Langs,
Technologies, Servers, ext Under language we are provided with
Number of Languages to program like C#, VB, J#, VC++, ext Under
technologies we have be provided ASP.Net(Web Application
Development) ADO.Net (Data Base Communication), ext... Server play
a key role in develop on any application like data base servers(SQL
server) web servers(IIS), site Administration server (SHARE POINT),
Integration Server (Biz Talk). COM (Computer Object Model), before
.Net Micro Soft ware use COM. Micro Soft Inter chose.Net resolved
the problem under its own traditional Technologies COM.
Intermediate Code will control on JVM (or) CLR. JVM (or) CLR will
be called Frame work.Use of frame work:Operating System
Independency, Security, and Memory maintains framework. Managed
CodeFlat form Independency. Unmanaged CodeFlat form Dependency.
*** END OF THE DAY ***
Dt: 08-02-2010Frame work:-It was Software which makes the
functionality of a Operating System & makes the code to execute
under its control. By default Machine code execute directly under
the control of Operating System. Which as intermediate code execute
under the control of the frame fork. The Advantage of Executing
intermediate code under Frame Work will be,1. Flat form indecency
(or) Independency.2. Security.3. Memory Management. Because of the
above feature what it provides the code which execute under the
frame work environment is known as managed code and the code which
execute directly under the Operating system is known as unmanaged
code. Frame work is unmanaged code. NGWSNext Generation Windows
System. The development of .Net frame work has bean stored in the
late 90s originally under the name of NGWS. ISOInternational
Standard Organization.Ex: - C, C++ ECMAErosion Computer Manu
factional Association.
To develop the.Net Frame work Microsoft has first prepared a set
of Specification known as CLI Speciation (Common language
infrastructure). Those speciation ware standardized under ISO &
ECMA. NOTE: - The CLI specifications were open, which gives a
chance for every one to developed .Net Frame work. CLI
Specifications:- CLI specification covers the following rules,
CLSCommon language specification. CTSCommon Type Specification.
BCLBase Class Library. VESVirtual execution system. CLS: - A set of
Base rules all the .Net languages have to adapt to interoperate
each other. That is all languages after compilation of the generate
the same type of codes known as common language specification.
CTS:-A carding to this all the types under .Net languages was to
adapt the some data types structure. In the sance sizes of the
types should be uniformed between the languages. C# is a case
sensitive (lower case). VB.Net Not a case sensitive (Starting
latter Upper Case). As every .Net language has been derided from an
existing language the name of under the language might be
difference, but there sizes will be uniform. Every type used in
every language after compilation has to be converted into IL types.
Every type used under every language is getting converted to IL.
But when it gets consumed from any other language it set declared
in the other language understandable format only. NOTE: -CLS, CTS
were foundation for the language the inter operability which was
made possible under .Net languages.
*** END OF THE DAY ***
Dt: 09-02-2010
Library:-A set of prepaid functionalities.Base class Library
(BCL):- A library is a set of predefined functionalities were every
language provides the languages.
Libraries are traditional language were specifies to the
language. Were as libraries under .Net languages were common to all
languages. Microsoft provided the libraries in the form of base
class library for congestion in .Net languages. Most of the base
class libraries were implemented in c# language.
NOTE:- Base class libraries were the best example for language
intractability provided under .Net languages. BCL is a part frame
work class library.Frame work class library (FCL):- It was a
contractive set of libraries that was provided by Microsoft for the
execution of .Net framework & ASP.Net runtime. Under FCL BCL
was only a part what we can consumed. CLR is also a virtual
execution System.Virtual execution system (VES):- As we were
heavier time all the high level .Net languages get converted to IL
code after compilation. This IL code can be carried & executed
as any machine provided and Specific virtual system is available.
Which takes the responsibility of learning IL code into machine
code according to Operating System and Hardware.
Note:- The virtual execution system was the foundation for
Operating System independency which was make possible under .Net
languages. Following the above CLI specifications Microsoft has
implemented party company mono (Subsidiary of novel) has
implemented the frame work for few other machines like UNIX, Linux,
Sun Solaris, and MAC-OS.Note:- .Net has theoretically flat form
independent between there is a chance of implemented the frame work
for any Operating System making use of the open CLI specification.
But practically implementation was given only for few machines. The
.Net framework has launched in the year 2000 as 1.0 Beta 1(trail
version) from then number of changes made to it were the current
version was 4.0.
Versions release of .Net framework
2000-1.0 Beta 1 2001-1.0 Beta 2 2002-1.0 RTM 2003-1.1 2005-2.0
2006-3.0 2007-3.5 2009-4.0Important Data:-ADO.Net-Communication
with database.ASP.Net -For developing to web
application.RTM-Realize to Manufacture (its a production
version).3.0 Version WPF-Windows Prosecution foundation.WCF-Windows
Communication Foundation.WF-Windows workflow function (Its only for
administration).Card Space-Its only for administration. 3.5 Version
LINQ-Modern TechnologiesADO.NetEntity Framework.
*** END OF THE DAY ***
Dt: 10-02-2010
.Net Frame Work Architecture:-
Common Language Run Time: -Its the code component under the .Net
framework which was Responsible in convention IL code into machine
& execute it. Base Class Library (BCL):- It was set of common
functionalities the available through out all the .Net languages.
Win forms technologies is used in the development of windows
application (Graphic user interfaces). ASP.Net Technology is used
in the development of web applications using .Net languages.
ADO.Net Technology is used for communication with data Sources
(Data base file, exe WPF (Window Prosecution foundation) was a
technology all so used in the development of GUI only. With a
support for Graphics, animations, 2D & 3D Images. Which was not
available under traditional win forms. WCF (Windows Communication
foundation)is a technology used in the development of distributed
application. LinqLanguage integrated query was also used for
interaction with data sources, objects and collections. ADO.Net
Entity Framework is similar to link but a execution for traditional
ADO.Net.Futures of .Net:-- Language Independency: the .Net
framework introduces a common type system, or CTS & CLS
Specification defines all possible data types and programming
constructs supported by the CLR and How they may or may not
interact with each other. Because of this feature the .Net
framework support the exchanges of instances of types between
programs written in any of the .Net languages.
BCL:- The BCL part of Framework Class Library (FCL),is a library
of functionality available to all languages using the .Net
framework. The BCL provides classes which encapsulate a number of
common functions.
Portability:- The design of the .Net framework allows it to
theoretically be flat form independent and thus cross flat form
compatible, that is a program written to use the framework should
run without changes on any type of system for which the framework
is implemented. Microsoft implementations of the framework cover
windows. In addition Microsoft submits the specifications for CLI
(Which includes core class, libraries, CTS, and the CIL)to both
ECMA & ISO, Making them available as open standards. This makes
it possible for third parties to create compatible implementation
of the framework on other flat form.
Simplified deployment: - Installation of computer software must
be carefully managed to ensure that it dont interface with
prevision ally installed software and it conforms to increasingly
stringent security requirement. The .Net framework includes design
features and tools like packing and deployment that help address
those requirements.
*** END OF THE DAY ***
Dt: 11-02-2010Common Run Time Engine:-Programming language on
the .Net framework compiled into an IL known as CIL. In Microsoft
implement the IL is not interpreted but rather compiled in a manner
known as JIT (Just-In-Time) compiler into native code. In this from
of conversions it adapt few optimization techniques like, 1.
Conversion graduals during the program execution. 2. Conversion of
only the request code which should be executed.3. Strong of the
converted code in volatile memory for next time use.Memory
Management: - It is the act of managing computer memory. In its
simple form this involves providing ways to allocate pretensions of
memory to programs but their request & Freeing it for reuse
when no longer needed. The management of main memory is critical to
the computer system. In this process it user the Garbo collection
which is the automated allocation and de-allocation of computer
memory resources for a program. This is generally implemented of
the programs language level and is in opposite to named memory
management. The explicitly memory allocation and de-allocation of
computer memory resources. In computer science, garbage collection
is a from of automatic memory management. The garbage collection or
just collection attempts to radian garbage or memory used by
objects that will never be accessed again by the
application.Garbage Collection was invented by Jun Mccarthy around
1959 to solve the problem of manual memory
management.Inter-operability :( Technology Inter-Operability):- COM
(Computer Object Model) it was a specification which advices not
build software as a monolithic unit (single unit).In spite it
advises building the software by dividing into smaller components
or libraries and then integrates as software, which provides the
feature like ease maintenance of software and Reusability.
COM is operation system dependent specially
windows.Intractability:- Because introduction between older and
newer application is commonly required the .Net framework provides
means to access functionality they was implemented in programmer
that executes outside the .Net environment in this process access
to COM components is provided under the system dot runtime dot
intractability services of the frame work.RCM: -Runtime callable
wrapper in exposes the unmanaged COM interfaces as Managed .Net
interfaces to a .Net application.CCW:-COM Callable wrapper this
exposes managed .Net interfaces as unmanaged COM interfaces to a
COM application.
*** END OF THE DAY ***
Dt: 12-02-2010Concerns & Criticisms related to .Net:-
Applications running in a managed environment such as the Microsoft
frameworks CLR or Javas JVM tend to require more system resources
than similar applications that access machine resources more
directly. Some application, however, have been shown to perform
better in .Net than in their native version. This could be due to
the runtime optimization made possible in Just-In-Time compilation
of managed code, or other aspects of the CLR like Garbage
collection. As JIT languages can be more easily reverse engineered
than native code to algorithms used by an application there is
concern over possible lass of trade secrets and the by passing of
license control machines many obfuscation techniques already
developed, however, can help to prevent this; indeed Microsoft
visual studio 2005(.Net 2.0) includes such a tool. In a managed
environment such as the Microsoft frameworks CLR or Javas JVM the
regularly occurring Garbage Collection for Declaiming memory
suspends execution of the application for an unpredictable lapse of
time (Typically not more than few milliseconds). Since the
framework is not preinstalled on older versions of windows an
application that requires it must verity that it is present and if
it is not, guides the user to install it. Newer versions of the
framework (3.0 & up) and not pre-installed on any version of
the windows Operating System, as some developers have expressed
concerns about the large size.C Sharp (Programming Language):- C#
is an object oriented programming language developed by Microsoft
as part of the .Net initiative and later approved as a standard by
ECMA and ISO. Ander Hejlsberg leads development of the C# language,
which has a procedural, object oriented syntax based on C++ and
influences from as pets of several other programming languages
(most notably Delphi & Java) with a particular emphasis on
simplification. History:- During the development of .Net, the Class
Libraries were originally written in a language called Simple
Managed C (SMC). In January 1999, Anders Hejlsberg formed a team to
build a new language at that time called Cool, later the language
had been renamed C# and the class libraries and ASP.Net runtime had
been ported to C#. C#s principal designer and lead architect at
Microsoft is Anders Hejlsberg, who was previously involved with the
design of Visual, J++, Borland Delphi and Turbo Pascal Languages.
In interviews & technical papers he has stated that flaws in
most major programming languages (Ex: - C++, Java, Delphi and
Smalltalk) drove the fundamentals of CLR, which, in turn drove the
design of C# programming language it self.
*** END OF THE DAY ***
Dt: 15-02-2010Design Goals:- The ECMA standard list these design
goals for C#. It is intended to be a simple, modern, general
purpose and object oriented programming language. The language
should include strong type checking, array bounds checking, and
detection of attempts to use uninitialized variables, sources code
portability and automatic garbage collection. The language is
extended for use in developing software components that can take
advantages of distributed environments. Programmer portability is
very important especially for those programmer already familiar
with C and C++. Support for intended to be suitable for writing
applications for both hosted and embedded systems.Versions: -1.0,
1.5, 2.0(ECMA), 3.0Note: -C# 3.0 is not currently standardized by
any standards organization, but it is expected that it will also
become an ECMA & then standard as its early versions. Features
of C# 2.0:- Partial classes which allow class implementation across
more than one source file. Generics or parameterized types. Static
class that cannot be in satiated, and that only allows static
members. Anonymous delegates. The accessibility of property
assessors can be set independently. Null able value types which
provides improved interaction with SQL databases. Coalesce operator
(??) returns the first of its operands which not null (or null, if
no such operated exists).Features of C# 3.0:- Language integrated
query. Object initializes and collection initializes. Anonymous
types. Implicitly typed arrays. Lambda expressions. Automatic
properties. Partial methods. C is procedural oriented language.
Programming structure and various languages.
C Program Collection of functions.
Void main() cd csharp7> dir Csc D:\> csharp7> ExampleMy
first program.Note:- we can write code either by using visual
studio .Net or under any text editor like note pad. Which required
manual compilation and execution.Writing the first program:- Open
the notepad and write following code in it.class Example{static
void Main()}System.Console.WriteLine(My first program);}}Note:-
Save the program we were provided with Csharp compiler which was a
command line utility which should be used from Visual studio
command prompt as following:csc To open visual studio command
prompt go to: Start menu programming MS visual studio visual studio
tools visual studio command prompt, click on to open and go into
the folder where your program was saved compile the program as
following:D :\> csharp7> csc example.cs Once the program
compiles successfully, generates example.exe which contains IL code
in it.Executing the program: Now from the same location where we
compiled the program use the following stmt to
execute:D:>\csharp7>example.Csc: c Sharp compiler.Ildasm:
(Intermediate Language Dis-Assembler):- It was tool using which we
can view the content of IL code. Which has to be use from visual
studio command prompt as well as follows: Ildasm Ex:-
D:>\csharp7> ildasm example.exe When we execute it opens a
window in which we find a node with our class name expand it under
that click on the pink button beside the node Main, which displays
the code in a new window. System.Console.WriteLine Console is a
predefined class. System is called a name space, it is a logical
container in a class. File is a physical container, folder is a
logical container.
*** END OF THE DAY ***
Dt:17-02-2010System.Console.WriteLine:- Console was a predefined
class which provides standard IO functionalities that can be
performed on IO devices. It includes few static methods like
Write(print), WriteLine(Print and canalize line), ReadLine,
exe(ReadLine something like that Scanef). System is a name space
where a name space is a logical container of classes. Name spaces
for gives under the programming languages for two basis reasons.1.
Grouping up Related class.2. To overcome the name cosign, that is
defined of multiple classes with the same name can be done by
putting them under different Name spaces.
Importing a Namespace:- As every class has to be refund with a
name space for consumption these name spaces some time will be very
much length. In such case without suing the name space before the
class we can import a name space and consumed all the class under
them directly to import a name space we use using statement in C#
language and import statement in VB language.1. Using ;C#2. Import
VB
Ex:- using System;class UsingDemo{static void
Main(){Console.WriteLine(importing a namespace);}}
D:\csharp7>notepad UsingSystem.cs It will be directly open to
the in notepad under that using file name usingSystem.cs file
D:\>csc UsingSystem.csto compile the programming file. D:\>
cls UsingSystemTo run the programming file.
DATA TYPES:-
Integer Types:-ByteSystem.byte0-255ShortSystem.Int16
-32768+32767IntSystem..Int32 -2^31+2^31-1LongSystem.Int64
-2^63+2^36-1SbyteSystem.SByte
-128+127UshortSystem.Ulint160+65535(1)UintSystem.Ulint320+2^32-1(2)UlongSystem.Ulint640+2^64-1(4)
Decimal or Float types:-FloatSystem.Single4
BytesDoubleSystem.Double8 BytesDecimalSystem.Decimal16 Bytes
Boolean Type:BoolSystem.Booleantrue or false
Character type:Char System.Char2
bytesStringSystem.String(Variable in the length)
Root Type:-
Object System.Object
The size of char type is increase to 2 bytes to provide the
support for Unicode languages. All the language characters we call
it as an as key value, where as for other language characters its
known as Unicode values. Where Unicode values required 2 bytes
memory location for stored it. String is variable in size which
defends upon number of characters we align to it. Object type is a
capable to store any type of value under it. It get initialized
with 4 bytes but can be changed in runtime. Which is also a
variable length type.
Syntax for variable declaration:-
[][Const][readonly][=value][,n]Int x;public int y;const float
Pi=3.14freadonly String Str;bool b1, b2;
A constant and read only variable are one and the same which
cant be modified outside of the class and which they war declared.
Initialized a constant of the time of declaration mediatory. When
as in case of read only it was optional. A content cant modified
with in class also, but read only can be modified within the
class.
Ex:-String Str=100;int x = Str; invalid int x =
int.Parse(str);
Program:- VatDemo.cs
usnig System;class VatDemo{static void Main(){int x, y,
z;Console.Write(Enter x value:);x=
int.Parse(Console.ReadLine());Console.Write(Enetr y Value:);y =
int.Parse(Console.ReadLine());z= x+y;Console.WriteLine(Sum of {0}
&{1} is : {2},x,y,z);(OR)
Console.WriteLine(Sum of +x+&+y+is:+z);}}
*** END OF THE DAY ***
Dt:18-02-2010Note:-Parse Method:-It was a method under all the
data types responsible for converting a string a appropriate type
value.Ex:- int x = int.Parse(100)//Converts to intBool b=
bool.Parse(true)//Converts to boolFlaotf
=float.Parse(3.14f)//Converts to flaotNote:-the given value should
be compactable of being converted into the appropriate type
value.Ex:- int y =int.Parse(10x);//Invalid Data types ware
categorized into 2.1. Value type2. Reference type. Value types
store the data on the stack. Stack is a place where data is stored
in fixed length, such as int, float, ext Every program has its one
stark and no other program shares it allocated on program
execution. Stack work on a principle first in last out. Stack will
under the control of OS. Stack will dont provide dynamic memory
allocation and destruction. Stack is faster in access.References
Types:- C# support to pre-defended reference types string and
objects. Reference type store reference in a heap. Heap is the
second place where reference be stored instead on data. A .Net the
heap is now more managed is called managed heap. When application
create the first reference type memory is allocated for the type at
base address of managed heap. When the application create next
object the Garbage collector allocate memory for it in the address
base is available the garbage collection continues allocate place
new object in this manner. Ex:- int x = 100;String s = Hello;
Null-able Value types (2.0):-In the traditional languages and
earlier version a C# we have a program that is we cant store null
values in values types. They can only stored in reference
types.
Ex:- String s = null;//Validint x =null;//invalidBecause of this
which interactive with SQL database we will be facing a program, as
a database allows null values both in value types draw back from C#
2.0 we were provided with an option of storing null value under
value types also. Which has to done as following:int x =
null;Invalidint ?x = null;validdouble ?d= null;validImplicitly
typed variables(3.0): -It was an option which allows to declared
variable by using the keyword Var. which the data type of a
variable is decided depending upon the value we assigned it.Ex:-var
x =100;x is intvar s = Hello;s is stringvar f = 3.14f;f is
floatNote:- in this case declaring a variable without assigning a
value is not possible.Ex:- var y;invalid
Ex:-FindType.cs
using System;class FindType{static void Main(){var x =
100;Console.WriteLine(x.GetType());var f
=3.14f;Console.WriteLine(f.GetType());var
s=Hello;Console.WriteLine(s.GetType());var b =
true;Console.WriteLine(b.GetType());}}Note: - Get Type is a free
defined method which returns the type of a given variable.Note: -
Object is a heap memory.
*** END OF THE DAY ***
Dt: 19-02-2010Boxing & Un-Boxing:- If a value type was
stored on the managed help a reference type. Its known as
Boxing.Ex:- int x=100;Object obj=x; Boxing The Reverse of Boxing
that is Converting Reference type to value type is Un-Boxing.Ex:-
int y =(int) obj; Un-Boxing
Operators:-Arithmetic+,-,*,/,%Assignment=,+=,-=,*=,/=,%=.Comparison
==,!=,=,is, as, likeConcatenation+Increment & Decrement++,
--Logical&&, !!, ^ Conditional Statement:- A block of code
which executes basing on a condition is known as conditional
statement. There of 2 types,1. Conditional Branching(if, switch)2.
Conditional looping (while, do-while, for-each)Conditional
Branching:- these statement allow you to branch your code defending
on whether certain conditions were met or not. C# has 2 constructs
for branching code, the if statement which allows you to test
whether a specific condition is met, and the switch statement,
which allows you to compare an expression with a number of
different values.
Syntax:- if:- if();else if();----------------else;
Ex:- Ifdemo.csusing system;class Ifdemo{static void Main(){int
x, y;Console.Write(Enter X value:);x =
int.Parse(Console.ReadLine());Console.Write(Enter Y value:);y =
int.Parse(Console.Readline());if(x>y)Console.WriteLine(x is
greater);else if(x