Sunday, April 30, 2023

chimp paradox - 100 dying man to his grandson

1. Do what you want to do

2. Make contribution to the family, and the community/world

3. Exericse to make your body fit, and read to make your brain better

be specific: READ

Wednesday, April 26, 2023

Hug chatGPT, all in C#

I feel Visual Studio is way more powerful than Eclipse or IntelliJ Idea, in next few months/years, it could even improve a lot with chatGPT. chatGPT can guess and complete the leftover so it would be very effcient to develop with C#. What's more, chatGPT may make it easier to transform the C# code to Java/Python (With auto JUnit, Log added performance improved, cross-platform enabled).

Complete C# Master Class note 2

 1.

C# base virtual and child override behavior is same with Java. But C# can also have the new key word.

The new keyword is used to hide a method, property, indexer, or event of base class into derived class.

sealed doesn't allow override.

2.

Developers use the .NET Framework to create Windows desktop and server-based applications. This includes ASP.NET web applications. On the other hand, .NET Core is used to create server applications that run on Windows, Linux and Mac. It does not currently support creating desktop applications with a user interface.

3.

internal access modifier only allows same assemly/namespace/project access.

4.

struct is similar to class but it's value type. Struct cannot support inheritance.

CONSIDER defining a struct instead of a class if instances of the type are small and commonly short-lived or are commonly embedded in other objects.

5.

num8 = num6 ?? 8.53;

public delegate bool FilterDelegate(Person person);

            FilterDelegate filter = delegate (Person person)

            {

                return person.Age > 18;

            };

Display("Show adults",people,p=>p.Age>18);   //Lambda

Sunday, April 23, 2023

Complete C# Master Class note 1

 

1. C# variables defined in class level can be accessed by the method directly (without static keyword). Only if the variables are defined with static keyword, then they are shared by all instances. Variables defined within the method can only be used in the method.

2. decimal is used mostly in financial applications.

3. Value types hold the value directly on its own memory space. The value type uses a heap to store the value. Reference types store the memory location of the data, like string, class, array.

4.

// See https://aka.ms/new-console-template for more information

Console.ForegroundColor = ConsoleColor.DarkYellow;

Console.WriteLine("Hello, World!");

string? value = Console.ReadLine();

Console.WriteLine("You input {0}",value);

int n = Int32.Parse("32");//or int.Parse

Console.WriteLine(n);

Console.WriteLine($"Hello the value is {value}");

const double MYPI = Math.PI;

Console.WriteLine(MYPI);


string numberAsString = "128SDF";

int parsedValue;

bool success = int.TryParse(numberAsString, out parsedValue);

Console.WriteLine(success);

5.

destructor: ~Member()     Debug.write();

6.

By using the params keyword, you can specify a method parameter that takes a variable number of arguments. The parameter type must be a single-dimensional array.

7.

List<T> is a generic class. It supports storing values of a specific type without casting to or from object (which would have incurred boxing/unboxing overhead when T is a value type in the ArrayList case). ArrayList simply stores object references.

8.

Hashtable

foreach(DictionaryEntry entry in studentsHashTable){}

or

foreach(Student value in studentsHashTable.values){}


9. Dictionary implementation is actually based on Hashtable but it's generic and preferred.

10.

VS offers 2 automatic-watch tool windows: The Locals and Autos windows.

The Locals will show local variables of the current scope. It usually starts with this, which represents the current class.

The Autos window will show all variables used in the current line and in the previous line. These could be local variables, class members or static variables. The Autos also shows values returned from methods, which is useful at times.