Boxing – Enabling a value type to be treated as an object.
Code Example (C#):
1
2
3
4
5
6
7
| //Boxing
int a = 123;
//Unboxing
b = 123;
a = (int)b; // unboxing
object b = (object)a; // boxing |
Cast – A conversion from one type to another.
Code Example (C#):
1
2
3
| double a = 1.3425;
int b;
b = (int)a; //Cast double to an int |
Constraint – A condition on a type parameter that restricts the type argument you can supply for it. A constraint can require that the type argument implement a specific interface, be or inherit from a specific class, have an accessible parameter less constructor, or be a reference type or a value type.
Contract – A common set of members that all classes that implement the interface must provide.
Exception – The base class which contains an error message and other application data. The .NET framework defines hundreds of exception classes to describe different events, all derived from System.SystemException.
http://www.developerfusion.com/article/1889/exception-handling-in-c/3/
Code Example (C#):
1
2
3
4
5
6
7
8
9
10
| Try
{ }
Catch (System.IO.FileNotFoundExecption ex)
{
Console.WriteLine(“The file could not be found. “);
}
Catch (Exception ex)
{
Console.writeLine(“Error reading file: “ + ex.Messsage);
} |
Filtering Exceptions – A process used to filter through multiple exception classes and allow different responses depending on the exception. This can be achieved by using the Try, Catch and Finally Method.
Garbage Collection – A process were the runtime manages the memory used by the heap. Garbage collection recovers memory periodically as needed by disposing of the items that are no longer referenced.
Generic Type – A single programming element that adapts to perform the same functionality for a variety of data types.
Generic Type Parameters (C# Programming Guide)
http://msdn.microsoft.com/en-us/library/0zk36dx2(VS.80).aspx
Benefits of Generics (C# Programming Guide)
http://msdn.microsoft.com/en-us/library/b5bx6xee(VS.80).aspx
Heap – An area of memory where the actual data that address refers to is stored.
Interface - A common set of members that all classes that implement the interface must provide.
Narrowing – Happens when a value is converted from one type to another when the destination type can’t accommodate all possible values from the source. For example narrowing would happen when a double is type cast to an int.
Nullable type – A type of variable that can be used to determine weather a value has not been assigned, it allows the value to store a null value. If a bool type is Nullable then it can have a value of true, false, or null.
Code Example (C#):
1
2
3
4
| Nullable b = null;
//Shorthand notation, only for C#
bool? b = null; |
Signature – The return type, parameter count, and parameter types of a member.
Stack – Where instances of value types are stored in memory. Where the runtime can create, read, update and remove them quickly within minimal overhead.
Structure – User-defined types are also called structures or simply Structs. User-defined types are stored on the stack and they contain their data directly. In most other ways, structures behave nearly identical to classes.
Structure types should meet all of these criteria:
• Logically Represents a single value
• Has an instance size less than 16 bytes
• Will not change after creation
• Will no be cast to a reference type
Code Example (C#):
Unboxing – Converting back from a reference type to a value type after boxing has occurred.
Code Example (C#):
1
2
3
| //Unboxing
b = 123;
a = (int)b; // unboxing |
Widening – The opposite of narrowing when a value is converted to a different type where the destination type can accommodate all possible values from the source type. Widening would occur when an int is type cast to a double.
please wait...
Rating: 2.6/10 (43 votes cast)