Sunteți pe pagina 1din 14

Concept

Wednesday, April 9, 2014

Value type

8:04 PM

Stack

Reference Type Heap


Garbage collection to free object memory by destroying unused and non-referencing object
\n - new line
\a - alert
\b - Back Space
\r - Carriage Return
\t & \v - horizontal & Vertical tab
for each ( <data type> <index variable name> in <array variable>)
{
break;
continue;
}
Data Type

Array Method

Collection Method

Char & Bool 1

Size ( Byte )
S&H

Convert.

ToCharArray() Length

Sort()

ArrayList

Sort()

Int & float

Stack

ToInt32()

Clean()

Queue

Clear()

Double

Stack

IsFixedSize GetLength()

Stack

Add()

String

Variable

Heap

IsReadOnly GetValue()

Hashtable Remove()

Dynamic

Array

Rank

IndexOf()

Inset()
TrimToSize()
Reverse()

Syntax:
Using <filename>;
Using system;

Namespace <name>
{
<access specified> struct <name> // Stack
{
// Method & Variable
}
<access specified>[static] enum <name> { <variable name> = <default value>, } // Enum stack
/* Generic -> Reusability , Type Safety, Performence */
<access specified> [ [ [ abstract | sealed ] class ] | [ interface] ] <name> : <class | interface name> < generic_name > /* Class Reference Type heap */
{
/*Member Function*/
<access specifier> [static] [abstract ] <data type> <variable name> = <default value>;
/* Property */
<access specifier>[static] [abstract | virtual | sealed ] <data type> <property name>
{
Get
{
return <variable name | value>;
}
Set
{
<variable name>=value;
}
}
/* Indexer */
<access specifier> [<data type> | < generic_name > ] this [<data type> <index variable name>]
{
Get
{
return <variable name>[<index variable name>];
}
Set
{
<variable name>[<index variable name>] = value;
}
}
Public <constructor > ():base()
{
This.<variable name not parameter name>;
}
Public ~<destructor>()
{
}
C sharp Page 1

}
Public ~<destructor>()
{
}
/* Operator Overloading */
<access specifier> <class | interface name> operator <operator> (<data type> <parameter name>, )
/*Member Function*/
<access specifier>[static] [override | abstract | virtual | sealed] [<return type> | < generic_name > ] <method name> ([params] [ref | out ] <data type> <parameter name>, )
{
}
public static void Main(string[] args)
{
//Instance Class
<class name> < generic_name > <object name> = new <class | struct | enum name> < generic_name >();
<object name>.<method name>( <argument name>:<value>,)
/* Array */
<data type> [ , ] <array name> = [ new <data type>[ n ] | { <value optional>, } ]
/* Array List */
ArrayList <variable name> = new ArrayList();
Console.WriteLine();
Console.ReadLine();
}

}
}

C sharp Page 2

C#
Thursday, February 27, 2014

5:15 PM

OOPC
OOPC models real-world systems
OOPC is representation of real-world entity or object
Class made of attributes and methods
Consolidation of objects
Modularity object/class exists independent from each other via message and methods
Object can be modified without effecting the function of other object
ExtensibilityChange can be incorporated in existing system.
Makes program flexible to change
Helps in easy maintenance of software

Ref key word


e.g. Void <method/function name> (ref <data type> <variable name>){}
Out key word
e.g. Void <method/function name> (out <data type> <variable name>){}
const -> constant
Boxing

Object <O Name>= <variable name>

Unboxing <variable name>=<variable data type> <O Name>

C sharp Page 3

Structure - Value type


Class -Reference type-Inheritance-parameterized constructor
Constructor
Destructor
Finalize()
Dispose()

<Exception name>

Exception Handeling
Wednesday, April 9, 2014

11:05 PM

SystemException
ApplicatioException
Try
{
}
Catch ( <Exception name> <exception allies>, )
{
Throw caught;
Throw( new <exception class name>( <variable name> ) );
}
Catch ( Exception <E Name>)
{
}
Finally
{
}

<access specifier> class <exception class name>:ApplicationException


{
<access specifier> <exception class name>(<data type> <variable name>) : base ( <variable name> )
{
}
}

C sharp Page 4

Exception Concept
Thursday, April 10, 2014

2:22 PM

C sharp Page 5

Delegates & Events


Thursday, April 10, 2014

12:08 AM

<access specifier> delegate <return type> <D Name> ( <data type> <parameter>, );

<D Name> <name> = new <D Name> ( <function name> );


<name> += new <D Name> (<Function name>);
<D Name>();
<access specifier> event <D Name> <E Name>;
<E Name> = new <D Name>( <function name> );
<E Name>();

Covariance
Contra variance

C sharp Page 6

Attribute & Reflection


Thursday, April 10, 2014

12:28 AM

Predefined Attribute CLR


[attribute ( <positional parameter>, <name parameter>=value, )]
Element or Class Definition name
[Conditional("debug" | "trace")]
[Obsolete("<message>", true)]
[DllImport(.kernel32.dll.)]
[WebMethod(Description="<message>")]
ReflectType( "<name space>.<class | interface | struct name>");

Custom Attribute
[AttributeUsage
(
AttributeTargets.Class
|.Constructor
|.Field
|.Method
|.Property
,
AllowMultiple = True | Inherited | Validon
)]
Public class <PName> : System.Attribute
{
<parameter variables>
<Constructor>(<parameters variable>){}
<property>
}
[<name>(<parameters>,<property>=<value>)]
Type <Tname> = typeof(<class or element name>);
Foreach()
Object <OAName> in <T Name>.GetCustomeAttributes(false)
MethodInfo <Mname> in <T Name>.GetMethods()
Attribute <OAName> in type.GetCustomeAttributes(true)

<PName> <name> = (<PName>) <OAName> ;

C sharp Page 7

Multithreading
Wednesday, April 9, 2014

11:20 PM

Thread <name> = Thread.CurrentThread;


<name>.Name=<name>;
<name>.Priority = ThreadPriority.[Highest | Lowest |[Above_ | Below_] Normal ]
ThreadStart <TS Name> = new ThreadStart(<function or method name>);
Thread <name> = new Thread ( <TS Name> );
<name>.Start();
<name>.<method>

Monitor.Enter(<function name>|this);
<statemant>
Monitor.Exit(<function name>|this);
Lock (<function name>|this);
{
<statement>
}

C sharp Page 8

Unstarted
Runnable
Not Runnable
Dead
System.ApplicationDomain
Multithreading Method

Exception

Start()

Abort()

ThreadAbortException

Sleep()

Interrupt()

Wait()

Pulse()

Suspend()

Resume()

Threading Output
Friday, March 21, 2014

Without
Lock & monitor

12:34 AM

With Lock

With both
Waite

C sharp Page 9

With all

File Stream Input & Output


Wednesday, April 9, 2014

11:03 PM

FileStream

BinaryReader BinaryWriter StreamReader StreamWriter StringReader StringWriter DirectoryInfo


Binary File

Method

FileInfo

Method

Attributes

Create()

Attributes

Create()

CreationTime

Delete()

CreationTime

Delete()

Text File

FileMode.

FileShare. Close()

Close()

Append

Inheritable

BaseStream. BaseStream.

Close()

Create

None

CreateNew

Read

Seek()

Open

ReadWrite

SeekOrigin.

Close()

Peek()
Seek()

CreateSubdirectory() Directory

Open()

Exists

GetDirectories()

Exists

OpenRead()

Extension

GetFiles()

Extension

AppendText()

OpenorCreate Write

ReadBoolean Begin

FullName

FullName

Truncate

ReadInt32()

LastAccessTime

LastAccessTime

FileAccess.

ReadDouble() End

Read
ReadWrite

Current

LastWriteTime

Flush()
Read()

Write()

Write

Flush()
Read()

Write()

ReadLine()

WriteLine()

Length
Name

/* FileStream- File name & mode, access, file share (enumerator) */


FileStream <FS Name> = new FileStream(<file name>, FileMode.<method>,FileAccess.<method>, FileShare.<method>)
Stream | Binary Reader |Writer <SR Name> = new StreamReader (< FS Name>)
/* Peek() Returns -> integer value representing next available character OR -1 for NULL
Seek()*/
<SR Name>.BaseStream.Seek( <offset integer Backward(-ve) Forward(+ve) >, SeekOrigin.<Begin | Current | End>)
String str = <SR Name>.<SR method>
<SR Name>.Close()
<FS Name>.Close()
/* Directory & FileInfo */
DirectoryInfo <D Name> = new DirectoryInfo(<file location path>)
FileInfo [] <F Name> = <D Name>.GetFiles()
<D Name>.<method>
Foreach (FileInfo <FI Name> in <F Name>)
{
<FI Name>.<FI Method>
}

C sharp Page 10

Name

File Stream Description


Thursday, April 10, 2014

3:44 AM

A
Stream Reader

Directory Info Property

C sharp Page 11

2q

C sharp Page 12

Theory
Thursday, April 10, 2014

5:05 AM

Common Language Runtime (CLR)


.net program technology executed
Compilation
Memory Allocation
Garbage Collection
Rules Common Language Specifier (CLS)
Object interaction of different language
Class that follows rules CLS-Compliant
Defined Types System safety
Common Type System(CTS) data type common across all language
Managed Heap
Compiler Program Code -Assembly-> ( IL + Metadata ) -JIT-> Machine Language
Name space for code in assembly

C sharp Page 13

.Net CLR Concept


Thursday, April 10, 2014

2:30 PM

CH14

C sharp Page 14

S-ar putea să vă placă și