Friday, October 21, 2016

Head first C#

metacognition: trick your mind

  • your brain craves novelty. It’s always searching, scanning, waiting for something unusal.It was built to help you stay alive.
  • It doesn’t bother saving the boring things; they never make it pass the “this is obviously not important” filter.
  • How does your brain know what’s improtant. like tiger. like the danger of fire. what happens in your body? Neurons fire. Emotions crank up. Chemical surge. so your brain knows…
  • Imagine you are siting in a safe, warm, tiger-free zone. You are studying for an exam or trying to learn some tough technical topics which will take a week. Your brian is trying to do you a big favor. The brain’s scarce resources are better spent storing the really big things, not this obviously non-important, non-urgent content.
  • what turns your brain on? Make it visual. Use a conversational style. think more deeply. touch the emotions. ( you remember what you care about. You remember when you feel something)
  • the slow way to learn is sheer repetition. The faster way is to do anything that increase your brain activity, especiallly different types of brain activity.

visual application in 10 minutes

I use visual studio 2012, some buttons changes locations in different versions.
  • new project-> windows forms application, name it. you will get 3 .cs files, of which [design] is used as graphical coding;
  • toolbox -> pictureBox, drag and drop
    rightup corner of the picture has a property arrow -> import image
  • in Form1.cs, add one line inside the Form1_Load method:
    private void Form1_Load(object sender, EventArgs e)
            MessageBox.Show("Contact List 1.0. \nWritten by: Yuchao", "About");
  • debugging / stop debugging
  • In Solution Explorer, xx project->add -> New Item-> Local Database, name it
  • In Database Explorer, xx.sdf, Table ->creat table, set the first column as primary key and true identity, input the desired Database.
  • Project -> new data source -> database -> dataset -> next -> tables -> Finish
  • Datasource, drag and drop xx table, customize as you like.
  • project -> property ->publish -> publish now

.Net Framework

Buttons, checkboxes, lists, etc are all pieces of the .Net framework. It’s got tools to draw grpahiscs, read and write files, manage collections of things. The tools in the .Net framework are divided up into namespaces.
there’s nothing more attactive to a kid than a big sign that says, “Don’t touch this!” Come on, you know you’re tempted…
  • C# and .Net have lots of buit-in features
  • IDE chose a namespace for your code, e.g. your project’s namespace
  • your code is sotred in a class called Program
  • Every C# program must have exactly one “entry point” method that reads static void Main()
  • code snippet: for+table+table
  • when a new object is created from a class, it’s called an instance of that class
  • static method can be called without an instance
  • methods in a static class are all static
  • An object’s hehavior is defined by its methods, and it uses fields to keep track of its state.
  • Methods are what an object does.
  • Fields are what the object knows.
Due to time strain, I stop here. But I would definetely go back and spend one week to do the interesting excises in the remaining of the book.