2013年7月15日 星期一

firefox media player 播放音樂不能播放

更新完了 firefox 21 後,發現以前上的網站用 media player 播放音樂不能播放了,重新安裝 firefox 和 media player 插件都不能解決,問題找錯方向了。
原來問題是 firefox 21 更新後,設定預設不同了,關閉一個設定。如何設定看下面
首先在 firefox 的地址欄上輸入 about:config , 按 enter 進入,會有警告字句提醒小心修改設定可能引起 firefox 不穩定,按確定進入下圖,

  1. 地址欄上輸入 about:config
  2. 在 search 欄輸入 plugins.load_appdir_plugins
  3. 在 Preference Name 就會看這個項目,雙擊 value 改成 true
修改後,關閉 firefox 重開就行了。

2013年7月14日 星期日

C# 操作、型式和變數:Operators, Types, and Variables


 C#中,一定要宣告變數的型態!
Example 1: Boolean
using System;

class
Booleans
{
    public static void Main()
    {
        bool content = true;
        bool noContent = false;

        Console.WriteLine("It is {0} that C# Station provides C# programming language content.", content);
        Console.WriteLine("The statement above is not {0}.", noContent);
    }
}
 
 Example 2:
using System;

class Unary
{
    public static void Main()
    {
        int unary = 0;
        int preIncrement;
        int preDecrement;
        int postIncrement;
        int postDecrement;
        int positive;
        int negative;
        sbyte bitNot;
        bool logNot;

        preIncrement = ++unary; // unary+1
後印出
        Console.WriteLine("pre-Increment: {0}", preIncrement); //
印出1unary = 1

        preDecrement = --unary; // unary-1
後印出
        Console.WriteLine("pre-Decrement: {0}", preDecrement); // 印出0unary = 0
        postDecrement = unary--; // unary
後印出-1
          Console.WriteLine("Post-Decrement: {0}", postDecrement); //印出0 unary = -1
        postIncrement = unary++; // unary
後印出+1
          Console.WriteLine("Post-Increment: {0}", postIncrement); //印出-1 unary = 0
        Console.WriteLine("Final Value of Unary: {0}", unary);

        positive = -postIncrement;
        Console.WriteLine("Positive: {0}", positive);

        negative = +postIncrement;
        Console.WriteLine("Negative: {0}", negative);

        bitNot = 0;
        bitNot = (sbyte)(~bitNot);
        Console.WriteLine("Bitwise Not: {0}", bitNot);

        logNot = false;
        logNot = !logNot;
        Console.WriteLine("Logical Not: {0}", logNot);
    }
}
Example 3: Array
 using System;

class Array
{
    public static void Main()
    {
        int[] myInts = { 5, 10, 15 }; //
向量myInts,由int[]接起來為整數!
        bool[][] myBools = new bool[2][]; //
jagged array,向量裡的一個向量(an array of arrays)。很像MATLAB裡的cell
        // 產生三個向量在myInts裡
        myBools[0] = new bool[2]; // 初始化(new),產生boolean值,有2個元素
        myBools[1] = new bool[1]; 
// 初始化(new),產生boolean值,有1個元素
        double[,] myDoubles = new double[2, 2];
        string[] myStrings = new string[3];

        Console.WriteLine("myInts[0]: {0}, myInts[1]: {1}, myInts[2]: {2}", myInts[0], myInts[1], myInts[2]);

        myBools[0][0] = true; //
myBools[0]有2個元素,其元素再加用一個[]來指定!
          myBools[0][1] = false;
        myBools[1][0] = true;
        Console.WriteLine("myBools[0][0]: {0}, myBools[1][0]: {1}", myBools[0][0], myBools[1][0]);

        myDoubles[0, 0] = 3.147;
        myDoubles[0, 1] = 7.157;
        myDoubles[1, 1] = 2.117;
        myDoubles[1, 0] = 56.00138917;
        Console.WriteLine("myDoubles[0, 0]: {0}, myDoubles[1, 0]: {1}", myDoubles[0, 0], myDoubles[1, 0]);

        myStrings[0] = "Joe";
        myStrings[1] = "Matt";
        myStrings[2] = "Robert";
        Console.WriteLine("myStrings[0]: {0}, myStrings[1]: {1}, myStrings[2]: {2}", myStrings[0], myStrings[1], myStrings[2]);

    }
}
And here's the output:
myInts[0]: 5, myInts[1]: 10, myInts[2]: 15
myBools[0][0]: true, myBools[1][0]: true
myDoubles[0, 0]: 3.147, myDoubles[1, 0]: 56.00138917
myStrings[0]: Joe, myStrings[1]: Matt, myStrings[2]: Robert


2013年7月13日 星期六

開始幹C# (Getting Started with C#)

C# 分大小寫 (case-sensitive)
 註解  /* ... */

Example 1:

using
System; // 查考System空間,所以我們可以用這空間裡的很多種code (referencing the System namespace )
 

 class Welcome // class可包有data和method來執行;complie完後會有個叫Welcome.exe的檔案
{
    // Main begins program execution.// 方法 method     
    static void Main()  
   // 程式最一開始進入的地方(entry point);Main是保留字;static表示這method只能在這class用!
  // 每個method都有傳回值(return),這邊是void,表示不傳回東西。
    {
        // Write to console
        Console.WriteLine("Welcome to the C# Station Tutorial!"); 
      //  Console是System空間裡的一種class,WriteLine是Console裡的一種method。
     // 如果不用using System,那就必須寫System.Console.WriteLine(...)     
   }
}


 class和method都用{ (left curly brace)和 } (right curly brace)包起來。

Example 2: 輸入command在console裡面

// Namespace Declaration
using
System;

// Program start class
class NamedWelcome
{
    // Main begins program execution.
    static void Main(string[] args) // args是丟進來的東西;string[]指接進來的東西是字串型式。
    {
        // 假如在console輸入 NamedWelcome PK,則args[0]接受了字串PK,前面的{0}代表接受了第0個字串,
       // PK取代了{0}
          Console.WriteLine("Hello, {0}!", args[0]);
        Console.WriteLine("Welcome to the C# Station Tutorial!"); 

       Console.ReadKey(); // 把console停住,不自動關掉。
    }
}


Example 3: 使用者輸入

// Namespace Declaration
using System;

// Program start class
class InteractiveWelcome
{
    // Main begins program execution.
    public static void Main() //加了public,這個class以外的class都可以叫這個method!
   // 預設是private,就是在這個class裡才能被使用!
    {
        // 用Write代表寫到console上,並停留在這一行。
        // 用WriteLine代表寫到console上,並跳到下一行。
        Console.Write("What is your name?: ");
        Console.Write("Hello, {0}! ", Console.ReadLine()); // 等使用者輸入和按Enter!


// 上面也可寫成
//string name = Console.ReadLine();
//Console.Write("Hello, {0}! ", name);

 
            }
}