CSharp Unity Mobile App Project 1
Click the image or Inspirational Quote Generator for Android Mobile Devices and Windows
What did I learn from this Unity Mobile Application Project:
C# C Sharp:

C# has a Dictionary Data Type, it's a part of the System.Collections.Generic namespace

I can say I know C#.net now because System.Collections.Generic is a namespace in the .NET Framework, including in C# and Unity.

foreach loop is used to iterate over a collection, such as an array, list, dictionary, or any other enumerable type

var keyword is used to implicitly declare a variable without specifying its type. The compiler automatically determines the type of the variable based on the right-hand side of the assignment or the context (like a loop or a method return value)

Dictionary myDictionary = new Dictionary();

foreach (var pair in myDictionary)
{

}

var pair:

var is an implicit type. The C# compiler automatically determines the type of pair based on the collection you're iterating over.

So, pair is a KeyValuePair, which holds both the key and the value.

So pair is actually a variable of type KeyValuePair, which holds two pieces of data

pair.Key gives you the key

pair.Value gives you the corresponding value

dictionary hashes the keys internally.
Can You Access Items by Index?

No - you can't access a dictionary's values by a numeric index like quotes[0] or quotes[1]. It's key-based only.

A Dictionary in C# is built on a hash table

dictionary["myKey"] is very fast because it doesn't search through the collection; it just jumps to where it expects the data to be based on the hash

NET Core and Later Versions: Small Twist

Maintains index order No (but insertion order is preserved in newer .NET versions)

That change was mainly for developer convenience, not to make Dictionary work like a List.

In .NET Core 3.0+ and .NET 5+, Microsoft did start making insertion order predictable for Dictionary

When you create a Dictionary (or most other objects in C#), the data is stored in your program's memory - specifically on the heap.

Here's how it works:
1) Heap vs. Stack in C#

Stack: Used for storing simple values and method call info (like int, float, local variables).

Heap: Used for storing objects, including complex types like Dictionary, List, and user-defined classes.



Unity:

Mono is an open-source implementation of .NET, originally created by Xamarin

It allows Unity to run C# code on many platforms: Windows, macOS, Android, iOS, WebGL, etc.

Internally, Unity uses Mono to run it - but you're working with the .NET class library

Unity uses Mono as the runtime and relies on .NET libraries/APIs for scripting.

You're writing standard C# with access to most of the .NET Base Class Library.

You can apply your Unity C# skills to .NET-based applications (e.g., desktop apps, web apps, etc.) because they share the same .NET core libraries.



AI Software Application Development:

ChatGPT did a great job teaching me the concepts, I ended up using a Dictionary for this Mobile App because it suited storing an Author and Quote together efficiently.

Initially it said C# did not have a Dictionary but that may be because it thought I was talking about Python from the beginning of our conversation. It also recommended a list of Dictionaries but I may not have worded what coding goal I was trying to achieve to it. I've learned that asking direct questions with no extra information can sometimes provide a more accurate answer. But sometimes doing the opposite giving it a lot of information can allow it to tell me something new that I may have missed or not thought to ask about which can lead to adding a new feature to the program that makes it more interesting and useful.

Questions:


Inspirational Quote Generator for Windows Click the image or Inspirational Quote Generator for Android

__________Inspirational Quote Generator___________