+ All Categories
Home > Documents > .NET Fundamentals

.NET Fundamentals

Date post: 01-Oct-2015
Category:
Upload: venkat-rao
View: 220 times
Download: 2 times
Share this document with a friend
Description:
.NET BASICS
Popular Tags:
7
Checked : Checked data type is used to make sure that your left hand side data type is not getting overflowed with the assigned value. Unchecked : It’s almost same behaviour of the default behaviour (no checked or unchecked keywords). But for constant variables the compiler does default checks, so to avoid constant variable checks we need to use unchecked keyword. Regular Expressions: RegEx helps us to describe the complex patterns in texts. [] – alphanumbers ex: [a-f]—the characters between a to f are valid [0-9] – the numbers between 0 to 9 {} – length ex: {3} – the length will be 3 {1,3} – min length 1 and max length 3 () – specify it is a group and it can be OR or AND conditions ex: (com|net|in) ^ – start of your reg ex
Transcript

Checked: Checked data type is used to make sure that your left hand side data type is not getting overflowed with the assigned value. Unchecked: Its almost same behaviour of the default behaviour (no checked or unchecked keywords). But for constant variables the compiler does default checks, so to avoid constant variable checks we need to use unchecked keyword.

Regular Expressions:RegEx helps us to describe the complex patterns in texts.

[] alphanumbers ex: [a-f]the characters between a to f are valid [0-9] the numbers between 0 to 9{} length ex: {3} the length will be 3 {1,3} min length 1 and max length 3() specify it is a group and it can be OR or AND conditions ex: (com|net|in)^ start of your reg ex$ end of your reg ex

Collections:Group of records which can be treated as one logical unit.

Index based collections help you to access the record by using the internally generated index numbers.If you want get a record by using a key (user defined key) then you need to go for key value pair.Array and ArrayList:Array has fixed size and they are bound to specific data type i.e. arrays are strong type.

ArrayList is resizable and it can take any data type.

Arrays are faster than ArrayList. Arrays are strong typed while array list takes in an object datatype which leads to boxing and unboxing.

ArrayList and HashTable:

Queues: Queues are used to help us to implement first in first out methodology(FIFO)Enqueue() is used to add the object and Dequeue() is used to get the object from queue. These 2 functions are part of Queue object.Stacks: Stacks are used to help us to implement first in last out methodology (FILO)Push() is used to add the object and Pop() is used to get the object from queue. These 2 functions are part of Stack object.Special collections: These collection not famous in .net world and generic collections are better than special collections. Generics:If we want our collection to be strong type and also we want it to be resizable..this is the place where generics comes to picture. Generics separate the logic from the datatype and in this way we increase reusability.

Generic Collections:Generic collections helps us to separate the collection of the logics from the datatype.

Use of IEnumerable, ICollection, IDictionary & IList:Interface collections help us to send the collection from one layer to another layer in a control manner. All of these 4 are interfaces, so all good qualities of interfaces like decoupling, encapsulation and polymorphism can be benefited.Encapsulation you can control how much collection access should be given to the end client. In other words, you can implement encapsulation on your core collection i.e. ArrayList, HashTables etc.Polymorphism you can dynamically point to different collections on runtime. In other words, the same interface, you can point to Arralist or you can also point to Hashtable.IEnumerable this interface helps you to browse through the collection but it restricts the Add, Remove and other functionalities, so that we can implement the encapsulation over the collection.ICollection Same as IEnumerable (browse throught the collection) but it also helps you to display the count value.IList this interface is for ArrayList. Same as ICollection but it also helpts you to add/remove the collectionIDictionary - this interface is for HashTable. Same as ICollection but it also helpts you to add/remove the collection

IEnumerable v/s IEnumerator:

IEnumerable uses IEnumerator and IEnumerable is used to make your syntax very simpler. IEnumerable does not remember the states whereas IEnumerator remembers the states.If your requirement is just to loop through the collection then use IEnumerable. IEnumerator is required if you want to pass IEnumerator from one function to another function and want to remember the current position of the cursor.Var keyword:Var keyword defines the datatype statically and not on run time When your class names are big and if you want to create an object then the syntax looks complex interms of readability. If we use var key word this problem will be resolved.

Instead of the above line you can use Var as shown below:

Also useful in LINQ with anonymous types(if you are creating properties at runtime then it will be anonymous type in LINQ). In the below code, select new {Len=x.Length,value=x} represents anonymous types.

IComparable and IComparer:Both are used to implement custom sorting logic on your collectionIComparable will have only one sorting logic. IComparer will have multiple sorting logicGlobalization and Localization:If you design a system by keeping in mind that needs to be adapted to any languagecan be GlobalizationCustomizing your application for a given languagecan be Localization


Recommended