본문 바로가기

Software

Understanding Structured Exception Handling Terms of Software problem Bugs: These are, simply put, errors made by the programmer. For example, suppose you are programming with unmanaged C++. If you fail to delete dynamically allocated memory, resulting in a memory leak, you have a bug. User errors: User errors, on the other hand, are typically caused by the individual running your application, rather than by those who created it. For exam.. 더보기
System.Object In the .NET universe, every type ultimately derives from a base class named System.Object Core Members of System.Object Instance Method of Object Class Check Points Equals() be used to compare object references, not the state of the object if you override Equals(), you should also override GetHashCode() How to check member variables are same or not? public override bool Equals(object obj) { if (.. 더보기
Inheritance sealed prevents inheritance from occurring // The MiniVan class cannot be extended! sealed class MiniVan : Car { } Initialize Base Class // As a general rule, all subclasses should explicitly call an appropriate base class constructor. public SalesPerson(string fullName, int age, int empID, float currPay, string ssn, int numbOfSales) : base(fullName, age, empID, currPay, ssn) { // This belongs w.. 더보기
The Pillars of OOP Encapsulation: How does this language hide an object’s internal implementation details and preserve data integrity? private,protected, Accessor(get/set), properties(get/set) Inheritance: How does this language promote code reuse? is a, has a(containment/delegation model or aggregation) Polymorphism: How does this language let you treat related objects in a similar way? virtual, abstract, overrid.. 더보기
Static Defining Static Constructors A given class may define only a single static constructor. In other words, the static constructor cannot be overloaded A static constructor does not take an access modifier and cannot take any parameters A static constructor executes exactly one time, regardless of how many objects of the type are created The run-time invokes the static constructor when it creates an.. 더보기
Nullable ? and ?? // Define some local nullable types. int? nullableInt = 10; double? nullableDouble = 3.14; bool? nullableBool = null; char? nullableChar = 'a'; int?[] arrayOfNullableInts = new int?[10]; // Error! Strings are reference types! // string? s = "oops"; // Define some local nullable types using Nullable. Nullable nullableInt = 10; Nullable nullableDouble = 3.14; Nullable nullableBool = null; Nullable.. 더보기
Details Regarding Value Types and Reference Types Intriguing Question Value Type Reference Type Where is this type allocated? Allocated on the stack Allocated on the managed heap How is a variable represented? Value type variables are local copies Reference type variables are pointing to the memory occupied by the allocated instance What is the base type? Must derive from System.ValueType. Can derive from any other type (except System.Value Typ.. 더보기
Understanding C# Arrays MSDN C# Array Initialization Syntax Initialization of C# Array .... // Array initialization syntax using the new keyword. string[] stringArray = new string[] { "one", "two", "three" }; Console.WriteLine("stringArray has {0} elements", stringArray.Length); // Array initialization syntax without using the new keyword. bool[] boolArray = { false, false, true }; Console.WriteLine("boolArray has {0} .. 더보기
LINQ Line4 int[] numbers = { 10, 20, 30, 40, 1, 2, 3, 8 }; // LINQ query! var subset = from i in numbers where i < 10 select i; Console.Write("Values in subset: "); foreach (var i in subset) { Console.Write("{0} ", i); } Console.WriteLine(); 더보기
System Data Types and C# Shorthand Notation CLS-compliant .NET code can be used by any managed programming language. If you expose non–CLS-compliant data from your programs, other languages may not be able to make use of it The Data Type Class Hierarchy Notice that each of these types ultimately derive from System.Object, which defines a set of methods (e.g., ToString(), Equals(), GetHashCode()) common to all types in the .NET base class .. 더보기