Category Archives: Uncategorized

Swift 3.0 – Methods, Instance, Self

https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Methods.html#//apple_ref/doc/uid/TP40014097-CH15-ID236

Instance methods are functions that belong to instances of a particular class, structure, or enumeration. They support the functionality of those instances, either by providing ways to access and modify instance properties, or by providing functionality related to the instance’s purpose.

The Counter class defines three instance methods:

increment() increments the counter by 1.
increment(by: Int) increments the counter by a specified integer amount.
reset() resets the counter to zero.
The Counter class also declares a variable property, count, to keep track of the current counter value.

You call instance methods with the same dot syntax as properties:

Dictionaries (swift)

ref – http://jamesonquave.com/blog/swift-3-tutorial-fundamentals/

Dictionaries

Dictionaries are able to store values based on a key, typically the key is of type String, but it could actually be many different Swift types. In this example, we create a basic Dictionary with String keys and Int values for the age of each person:

We can access these values by their String keys:

result:
10
15

Note that we’re unwrapping these because they are optional values, and could potentially be nil. It is generally safer to use optional binding to unwrap the value from a Dictionary, especially if you have reason to believe the value could often be nil.

result:
Arya is 10 years old

We can also store arrays inside of dictionaries, or dictionaries inside of arrays, or a mix of both.

Here we have the dictionary like before. Except in this case, this dictionary is the value of key “Stark”, and key “Baratheon”.

In order to access, unwrap optional families[“Baratheon”]. It will give you an optional Dictionary. Unwrap it like this:

Then access the value at key “Tommen”, and the unwrap the optional int value.

Hence,

Tommen is 8 years old

The type of houses here would be [String: [String: Int]]
Or in other words it is a dictionary with a String key, and it’s values are [String: Int], another dictionary with String keys and Int values.

Sets

A Swift 3 Set is similar to an Array, except the values in a Set are unique and unordered.

Initializing a Set looks almost exactly like initializing an Array, the only different is the type:

This code creates a new set of type String. The greater than / less than symbols < and > are used to indicate Swift generic types, including the types of a Set as shown here.

You’ll notice we included “Blue” twice in our list, but if we print out the contents of colors, we only see it once:

result
[“Orange”, “Red”, “Blue”]

You may also notice that the ordering is inconsistent. Sets do not maintain any particular order for their contents.

We can not access members of a Set using indexes as we can with arrays, but instead we use the methods built-in to the Set type to add and remove objects. We can also call the contains method to check if the Set includes something.

result:

[“Black”, “Orange”, “Blue”]
true
false

Constructing sets of objects is a common way to catalogue what is included or excluded in a list of things, as long as there is no need to order or have duplicates of the objects.

Tuples

Tuples are not technically a collection, but instead simply multiple variables that can be passed around with a single identifier.

The type of the tuple here is (String, String), and we can manually access each numbered tuple element using dot-syntax, followed by the index:

result:
Quave
Jameson

Tuples can also be deconstructed in to new variable names:

Since we’re not using the last name here, we could just ignore that value by using an underscore _ and still deconstruct the first name:

let (first, _) = (“Jameson”, “Quave”)
print(first)
Jameson

Tuples are useful when you have a method that you want to return multiple values.

Swift – constants, variables, optionals

Swift 3 Tutorial – Fundamentals

Constants and Variables

Any Swift variable is either a constant or not.

constants and variables are just ways to describe terms that hold a value which can change (are mutable), and constants that can not be changed (becuase they are immutable)

To define a constant, use the let keyword

Example:

let name = “Jameson”
If you were to try and change the value of name, you would be unable to do so, and the Swift compiler would produce an error.

let name = “Jameson”
name = “Bob”
error: cannot assign to value: ‘name’ is a ‘let’ constant
name = “Bob”
~~~~ ^

On the other hand, by using the var keyword, we define a variable that can change

var name = “Jameson”
name = “Bob”
This code does not produce an error.

In general, you should always default to using the let keyword, unless you know you need a var keyword.

This leads to code that is ultimately safer. If you define a constant, and later attempt to modify it, you will get an error and at that time can determine if you should switch to use the var keyword, or if the error is giving you a hint that maybe you should rethink the current logic flow.

In general, immutability is preferred over mutability; it simply leads to less programmers errors and makes it easier to reason about your code.

Basic Types

In Swift, a type is indicated by declaring a variable, then putting a colon, followed by the type name. For example to declare an integer, which is of Swift type Int, you could use the following:

Or similarly, if you want to declare a string:

Swift supports type inference, which means the compiler determine what the type should be based on its initial value. Hence, you can usually omit the type information.

Working with Strings

It’s frequently useful to print a command to the console or otherwise evaluate a String containing other variables. For example, I might want to form a sentence with my variables age and name and print it to the console. I can do this using the + operator between each String.

result:
Robb is 15

A shortcut for this is to write your String as you normally would without the + operator separating each string, and put each variable inside of a set of parentheses, proceeded by a backslash \.

result:
Robb is 15

One thing you may have noticed is that age is now of type String because it was assigned the value “15” instead of just 15 without the quotes. This is because concatenating a String and an Int will not automatically cast the Int to String, which is a necessary step before concatenating is possible.

Non-Optionals and Optionals

https://drewag.me/posts/2014/07/05/what-is-an-optional-in-swift

What is the Problem
In C, it is possible to create a variable without giving it a value. This would look something like this:

If you were to try to use the value before assigning it a value, you would get undefined behavior (that is very bad).

In contrast Swift, for safety reasons, requires all variables and constants to always hold a value. This prevents that scenario where the value of a variable can be unknown. Thus, in swift, by default, we have non-optional values.

They always have a value. If you tried to assign nil to a non-optional variable, you will get a compiler error:

error: nil cannot be assigned to type ‘String’

Similarly, non-optional values can not be assigned to nil during their declaration:

error: variables must have an initial value

However, there are still cases in programming where one wants to represent the absence of a value.

A great example of this is when performing a search. One would want to be able to return something from the search that indicates that no value was found.
Thus, the concept of an optional is introduced:

An optional is just a variable that can be nil, null, or otherwise not set to any value.

How is an Optional Defined

To solve this problem, Swift created the type Optional that can either hold no value (None) or hold some value (Some). In fact, because Swift allows enums to have associated values, an optional is defined as an enum:

You declare an optional version of a type by adding a ? after the type name (String?).

Let’s use favoriteColor as an example. Many people have a favorite color, but it’s possible someone doesn’t, or we just don’t have the data. We would declare this variable as an optional, and not assign it to any value.

Implicit in the declaration of an optional with no value set, is the assignment to nil. We can verify this by examining the value of favoriteColor after declaring it as an optional by printing it to the console using the print() function.

result:
nil

We can later assign something to favoriteColor and see that it is no longer nil.


result:
Optional(“Blue”)

Note that instead of just getting the string “Blue”, we get Optional(“Blue”). This is because the value is still “wrapped” inside of the optional.

Unwrapping Optionals

  • optional binding
  • force-unwrapping

Before you use the value from an Optional you must first “unwrap” it. We consider an optional value “wrapped” because the real value is actually held inside the enumeration.

Let’s look at an example. Here we will declare two optionals, one called favoriteAnimal which is set to Fox, and one set to favoriteSong, which we will not set (it will remain nil)

You can unwrap an optional in both a “safe” and “unsafe” way

The safe way is to use Optional Binding:

In this case, we create a constant variable on the local stack. Assign our optional variable’s value to it, which is nil. the if/else statement evaluates the nil, and goes to the else block.


result:
I don’t know what your favorite song is!

Let’s employ optional binding to discover if each variable is set, and if so we’ll print a sentence containing the value to the console. First we’ll do it with favoriteAnimal. When we assign a constant to an optional Variable, it takes on the value. If the value exist, we make it print.


result:
Favorite animal is: Fox

In the event that the value is not set, we simply will trigger whatever is in the else block, or nothing at all if an else block isn’t specified.

Forced Unwrapping- you assert that it does indeed hold a value

A forced unwrapping, is an optional that doesn’t need to be unwrapped because it is done implicitly. These types of optionals are declared with an ! instead of a ?. Sometimes you know for sure that a variable holds an actual value and you can assert that with Forced Unwrapping by using an exclamation point (!):

If possibleString were None (did not hold a value), the whole program would crash with a runtime error and therefore, forced unwrapping is considered “unsafe”.

Implicitly unwrapped optional

ref – https://drewag.me/posts/2014/07/05/uses-for-implicitly-unwrapped-optionals-in-swift

There are a few main reasons that one would create an Implicitly Unwrapped Optional. All have to do with defining a variable that will never be accessed when nil because otherwise, the Swift compiler will always force you to explicitly unwrap an Optional.

Situation: A Constant That Cannot Be Defined During Initialization. In other words, WHEN YOU HAVE A PROPERTY THAT CAN’T BE POPULATED DURING INITIALIZATION.

Every member constant must have a value by the time initialization is complete.

Sometimes, a constant cannot be initialized with its correct value during initialization, but it can still be guaranteed to have a value before being accessed.

  1. the Optional is automatically initialized with nil, and can be printed only. However, if you try to dereference it, it will crash. Hence make sure you use chaining in order to dereference it
  2. the value it will eventually contain will still be immutable

However, the problem is, it can be a pain to constantly unwrap a variable that you know for sure is not nil via Forced Unwrapping, or Optional Binding.

Solution: Implicitly Unwrapped Optionals achieve the same benefits as an Optional with the added benefit that one does not have to explicitly unwrap it everywhere.

“Because the value of an implicitly unwrapped optional is automatically unwrapped when you use it, there’s no need to use the ! operator to unwrap it. That said, if you try to use an implicitly unwrapped optional that has a value of nil, you’ll get a runtime error.”

As long as your implicit optional is initialized during creation or at another time, you can access and it will be valid.

Like an optional, an implicit optional will also have nil by default during creation. We can initialize the creation of an implicit optional by assigning it data during creation, or at a later time as shown above. Then when we try to access it, it will be valid.

However, if we try to access it without some kind of initialization, we’ll get a compiler error like so:

an implicitly unwrapped optional promises the compiler it has a value when it is accessed

If you create an implicit optional, and somehow set it to nil at a later time, you’ll print out the nil instead.

Take Note

When you create a constant, this means the reference is immutable. That reference points to an object and that object only. you cannot change the reference to any other objects. Thus, by definition, you start off with the reference opVar2 pointing to a Optional object with data of type String. That’s why when you try to use it right after the declaration, you get a compiler error.

Result:

(lldb) po opVar2
▿ Optional
– some : “”

(lldb) po opVar3
nil

Because opVar3 is a mutable reference, it just points to nil as its default initialization. This means you can freely assign assign the reference to different String objects later.

ref – https://krakendev.io/when-to-use-implicitly-unwrapped-optionals/

A great example of this is when a member variable cannot be initialized in a UIView subclass until the view is loaded:

another example:

http://stackoverflow.com/questions/24006975/why-create-implicitly-unwrapped-optionals

1. A Constant That Cannot Be Defined During Initialization

Every member constant must have a value by the time initialization is complete. Sometimes, a constant cannot be initialized with its correct value during initialization, but it can still be guaranteed to have a value before being accessed.

Using an Optional variable gets around this issue because an Optional is automatically initialized with nil and the value it will eventually contain will still be immutable. However, it can be a pain to be constantly unwrapping a variable that you know for sure is not nil. Implicitly Unwrapped Optionals achieve the same benefits as an Optional with the added benefit that one does not have to explicitly unwrap it everywhere.

A great example of this is when a member variable cannot be initialized in a UIView subclass until the view is loaded:

Here, you cannot calculate the original width of the button until the view loads, but you know that viewDidLoad will be called before any other method on the view (other than initialization). Instead of forcing the value to be explicitly unwrapped pointlessly all over your class, you can declare it as an Implicitly Unwrapped Optional.

2. Interacting with an Objective-C API

Every reference to an object in Objective-C is a pointer, which means that it can be nil.
That means, that every interaction with an Objective-C API from Swift must use an optional where there is a reference to an object.

You could use a normal Optional in every one of these cases, but if you know for sure that the reference will not be nil, you can save yourself unwrapping code by declaring it as an Implicitly Unwrapped Optional.

Here, you know that the method will never be called without a tableView or indexPath.
Thus, the parameters are declared as implicitly unwrapped optional. You can safely use the dot operator
on tableView, and cellForRowAtIndexPath.

3. When Your App Cannot Recover From a Variable Being nil

This should be extremely rare, but if your app could literally not continue to run if a variable is nil when accessed, it would be a waste of time to bother testing it for nil.

Normally if you have a condition that must absolutely be true for your app to continue running, you would use an assert. An Implicitly Unwrapped Optional has an assert for nil built right into it.

4. NSObject Initializers

Apple does have at least one strange case of Implicitly Unwrapped Optionals. Technically, all initializers from classes that inherit from NSObject return Implicitly Unwrapped Optionals. This is because initialization in Objective-C can return nil. That means, in some cases, that you will still want to be able to test the result of initialization for nil. A perfect example of this is with UIImage if the image does not exist:

If you think there is a chance that your image does not exist and you can gracefully handle that scenario, you can declare the variable capturing the initialization explicitly as an Optional so that you can check it for nil. You could also use an Implicitly Unwrapped Optional here, but since you are planning to check it anyway, it is better to use a normal Optional.

Optional Chaining

Adding ? to the end of a type makes it Optional.
Adding ? to the end of an optional variable invokes Optional Chaining.

You specify optional chaining by placing a question mark (?) after the optional value on which you wish to call a property

…method or subscript if the optional is non-nil. This is very similar to placing an exclamation mark (!) after an optional value to force the unwrapping of its value.

The main difference is that optional chaining fails gracefully when the optional is nil, whereas forced unwrapping triggers a runtime error when the optional is nil.

Hence if you declare an optional object in your class, and you want to access that object’s properties, you must use the “?” on the optional object in order to get the valid unwrapped object. That you can continue to access the unwrapped object’s values. If you just use “.” without the “?”, the optional object is looked upon as an enum, and thus, you’ll get an error.

example:

we use ? after navigationController, this is called optional chaining
the reason why is because navigationController is an optional var.
in order to access properties of an optional var (or chaining),
we use someVar?.

if we do not do this, and try to use the dot notation to access properties straight on the variable like this:

essentially, what’s happening is that you are trying to access the enum of the optional var “someVar” instead. That is incorrect.

Thus, in order to access the properties of optional variable make sure to use

optional-chaining

Swift 3.0 – data structures

ref – https://www.raywenderlich.com/123100/collection-data-structures-swift-2

Arrays

  • An array is a group of items placed in a specific order, and you can access each item via an index — a number that indicates its position in the order. When you write the index in brackets after the name of the array variable, this is subscripting.
  • Swift arrays are immutable if you define them as constants with let, and mutable if you define them as variables with var.
  • In contrast, a Foundation NSArray is immutable by default. If you want to add, remove or modify items after creating the array, you must use the mutable variant class NSMutableArray.
  • An NSArray is heterogeneous, meaning it can contain Cocoa objects of different types. Swift arrays are homogeneous, meaning that each Array is guaranteed to contain only one type of object.
    However, you can still define a single Swift Array so it stores various types of Cocoa objects by specifying that the one type is AnyObject, since every Cocoa type is also a subtype of this.

The primary reason to use an array is when the order of variables matters. Think about those times when you sort contacts by first or last name, a to-do list by date, or any other situation when it’s critical to find or display data in a specific order.

Run time for Arrays

Accessing any value at a particular index in an array should usually be O(1)
Searching for an object at an unknown index will generally be O(n).
Inserting or deleting an object will often be O(1).

Dictionaries

Dictionaries are a way of storing values that don’t need to be in any particular order and are uniquely associated with keys. You use the key to store or look up a value.

Dictionaries also use subscripting syntax, so when you write dictionary[“hello”], you’ll get the value associated with the key hello.

Like arrays, Swift dictionaries are immutable if you declare them with let and mutable if you declare them with var. Similarly on the Foundation side, there are both NSDictionary and NSMutableDictionary classes for you to use.

When to use Dictionaries

Dictionaries are best used when there isn’t a particular order to what you need to store, but the data has meaningful association.

Sets

  • A set is a data structure that stores unordered, unique values. Unique is the key word; you won’t won’t be able to add a duplicate.
  • Swift sets are type-specific, so all the items in a Swift Set must be of the same type.
  • Swift added support for a native Set structure in version 1.2 – for earlier versions of Swift, you could only access Foundation’s NSSet.
    Note that like arrays and dictionaries, a native Swift Set is immutable if you declare it with let and mutable if you declare it with var. Once again on the Foundation side, there are both NSSet and NSMutableSet classes for you to use.

Using sitecore rocks on Visual Studio 2015

ref – https://www.cmssource.co.uk/blog/2012/June/basic-sitecore-development-tutorial-part-3-visual-studio-sitecore-connection

Sitecore Rocks is a VS plugin that allows us to easily access our Sitecore content from within VS. It saves time by bypassing the Sitecore development centre. The following steps highlight how to hook up sitecore rocks with our currently static Sitecore web project.

After installing Sitecore Rocks, a “Sitecore” menu will appear in your visual studios. Click on on it to open the sitecore dialog box.

connect_to_sitecore

  • Click on the ‘Connect to a Sitecore Website’ button as shown on the right. The connection dialog box will open up.
  • Select the ‘Hard-Rock Web Service’, which is specifically for the newer editions of sitecore, from the Data Provider drop-down.
  • Type the name of your website into the Host Name category, in this case: sitecorex.
  • Enter‘sitecore\admin’ into the User Name category and enter ‘b’ into the Password field.sitecore rocks connection

test_sitecore_connection

Browse for the location of the Website folder in the root directory of your Sitecore website and tick the ‘Automatically Upgrade Server Components When the Dialog Closes’ checkbox.

Hit the Test button. You should receive a pop-up saying ‘Yes, it works!’ if you’re successful.

If you’re prompted with a series of dialog boxes regarding upgrading the server components, click OK then check the Sitecore.Rocks.Server component checkbox, then click Update when prompted to update server components. Select the Website folder of the SitecoreX website (C:\inetpub\wwwroot\hadoken\Website) and click OK.

If a ‘Yes, it works!’ dialog box appears you’re successful. Click OK and you should see the sitecorex website content icon with drill-down ability appear on the left. You should be able to go into the contents of the website, in the master database, as it is shown within the Sitecore Content Editor.

SightCore Training notes

Everything in Sitecore is an item

An item is a unit of content, not a page

Items are not files

Each item has a GUID

Items are represented in a hierarchical structure called Content Tree

Sitecore interfaces display all or part of the Content tree.

Some items are addressable via URL.
Items’ URL is determined by position in the Content Tree.

work in Master database

Client browsers retrieves data from Web Database.
Synchronization between Master and Web database is called publishing.

Which experience editor mode would you use to add a new component? Designing mode

Desktop,
Content Editor,
Experience Editor

Sitecore is ASP.NET application

  • Master – authoring database, work in progress
  • Web – published, live content
  • Core – settings and membership

xDB – MongoDB NoSQL Collection starting with v7.5. Collects information. Then xDB aggregate and pushes them to Reporting DB.

Reporting
SQL server. Replaces Analytics DB previous to v7.5. Multi dimension data. Reporting search for analytics, which comes from Mongo. MongoDB has most detailed data.

File System

website – web root of ur application
database – database files
data – license, site core logs, packages, indexes

Installation Scenarios – recommended minimum
Server for CMS
DB server
Content Delivery server

When a request comes in, Sitecor maps URL to an item in the content tree, and dynamically assembles presentation

3 db that are installed by default: Web, Master, and Core

Foundation Features – content versioning, multi language, device

What is the name of the digital marketing management part of the Experience Platform that collects and aggregates contact information?
xDB

Creating Data Templates

– item is unit of data in SiteCore
– has fields organized into field sections. Field section mean group of fields

Data templates – needed to create item
– fundamental building block in Sitecore
– define a type of item
– determine what field sections, field types, and field names compose an item
– field types determine the editor control used in the tools. i.e Image, Rich Text…etc

Deciding the Data Structure Architecture

project should start with focus on designing your data structure (like sql schema)

Building Data Templates

Data Analysis, then build base Templates
Other templates inherit fields from base templates.

Content Base (base template for other templates)
– Heading
– Main Content
– Main Image

Easiest way is to use Sitecore Rocks.

Field Source – extra configuration. Different meaning for different field types.

Image – field source means where you can select images
Rich Text –

An inherited field source, cannot be overridden

An item’s type is determined by “Data template” used to create it.

What is an item composed of?
Field sections and fields

What do you need to specify when creating a new field?
field name, and type.

Inherited Structure

Field names should be “unique”, but field sections with the same name will “merge”.

System define fields by ID. but you only see the name. So try to have unique field names.
So in your derived template, make sure you don’t have the same field name.

However, if your section name is same, its okay, because the parent template and the derived template’s section will merge.

iN WHICH SCENARIO WOULD U use data template inheritance?
When fields are repeated in multiple data templates?

Why is it important to think of your data template creation and inheritance structure from the beginning?
Refactoring template inheritance may cause data loss.

By default, all data templates eventually inherit from which sitecore data template?

standard template.

What happens if the same field name is used in 2 separate inherited data templates?

fields do not merge
both fields will appear (with different ID, but same string)

Standard Values allow you to define defaults

Standard Values Item – Manually create

Child item of the data template
Includes the data template fields and all inherited fields
Always named __Standard Values

Standard Values and Inheritance

Tokens

Tokens are replaced the moment an item is created.

$name, $id, $time, $parented
you can add your own tokens programmatically

i.e:

Heading:
$name

Item is created
Item Name: Holiday

Heading:
“Holiday”

Describe the standard values item:

always named __Standard Values
child item of owning data template
is a special instance of an item – contains all inherited fields

What type of settings can be applied to standard values?
default field values, default insert options, default presentation, default Workflow

What are two types of default field values?

dynamic ( uses tokens ) and static.

How do tokens work?
Tokens are replaced when an item is created. For example, there are tokens for the name of the item or the ID of the parent item.

Name 3 tokens:

$name, $date, $id $parentID

What are Insert Options

Authors require a list of allowed item types (data templates)
Developers and admins are less restricted

Insert Options…
Define allowed child items
Allow authors to build multiple levels of content in the tree
Reduce risk of human error
Usually defined on standard Values
Can be overridden on an item

Insert Options

List of data templates that can be created/inserted under a specific item.

Where should Insert Options be configured?

On the data template’s standard values which can be overridden at item level.

Standard Values – is a child item of a data template and is the mechanism for defaults when items are created.
Field – single line text, rich text, image, general link…etc. type determines the interface that the author sees for editing that field.

Data template vs Standard Values

Data Template – field sections, fields, template icon, base template inheritance

Standard Values – default field values, default insert options….

Data Templates – inheritance, icon,
Data Template Standard Values – Default Values, Insert Options, Tokens

Presentation details?

Configuration that determines what an item looks like when requested by the browser

Break designs into units of reusable functionality.

Creating a Layout

One Layout for all items in our site

A Layout is a canvas or the ‘scaffolding’ for a site.
The training site BasicSitecore defines a single shared Layout for all items within the site.

Assign Layout on standard values (consider setting Layouts on base templates)

A layout is
an .aspx file on the file system
a corresponding Layout definition item in the tree
Linked by the Path field

Note: the item and the file can be referred to as a “layout”

Assigning a Layout
Items must have a Layout to be viewed as web pages

Items must have a Layout to be viewed as web pages
Layouts are part of an item’s presentation details
Recommended practice – assign layouts to the data template’s standard values
An item can have one layout per device ( mobile, print, rss )

Layout – .aspx file

Layout definition item connected to a layout file?
Path field on the layout definition item points to the location of the .aspx file

What is a Component?

Sublayout – (sitecore’s wrapper for a Web User Control)
XSLT Rendering
Sitecore Web Control

All components consists of…

Definition item in Sitecore:

/sitecore/Layout/Sublayouts
/sitecore/Layout/Renderings

File on the file system:

.ascx(Sublayout)
.xslt (XSLT rendering)

Linked by a Path field on definition item

A Sitecore Sublayout is:

– most commonly used component in a web forms implementation
– .ascx file on the file system

Interface

Boxing

Difference between Boxing and Unboxing in C#

Boxing

  • The first two lines of code declare and initialize value type variable i and reference type variable oi.
  • In the third line of code, you want to assign the value of variable i to oi. But oi is a reference type variable and must be assigned a reference to an object in the heap.
  • Variable i, however, is a value type and doesn’t have a reference to an object in the heap.
  • The system therefore box the value of i by doing the following:

    • Creating an object of type int in the heap
    • Copying the value of i to the int object
    • Returning the reference of the int object to oi to store as its reference

    Memory is allocated on the heap that will contain the value type’s data and the other overhead necessary to make the object look like
    every other instance of a managed object of reference type .
    The value of the value type is copied from its current storage location into the newly allocated location on the heap.
    The result of the conversion is a reference to the new storage location on the heap.

    Unboxing

    What is UnBoxing Conversion?

    Unboxing is the process of converting a boxed object back to its value type.Unboxing is an explicit conversion.

    The system performs the following steps when unboxing a value to ValueTypeT:

    It checks that the object being unboxed is actually a boxed value of type ValueTypeT.
    It copies the value of the object to the variable.

Lambda

Search for string in string array

lambda

Result:

otwone
two
threetwo
fotwour
two

LinQ

Result:

otwone
two
threetwo
fotwour
two

Determine if any ints are larger or less

Lambda

Result:

less than or equal to 3: 3
3
more than or equal to 7: 8
8
less than or equal to 3: 1
1
more than or equal to 7: 7
7
more than or equal to 7: 9
9
less than or equal to 3: 2
2
more than or equal to 7: 8
8

Find age in Array of Structs

linQ