水曜日, 6月 08, 2011

The formality problem: Java and C# -- extended class

Small things get in the way.

The way to write extended classes in Java and C# differs slightly.

Just for the record the following cases depicts the differences.


The extended class -- the case with Java:
public class NewClassTest
{
class A
 {
   int i=0;
   A(int i)
     {
        this.i=i;
     }
 }

class B extends A
 {
   B()
     {
        super(1);
     }
 }

public void test()
 {
   System.out.println(new B().i);
 }

public static void main(String args[])
 {
    new NewClassTest().test();
 }
}


The extended class -- the case with C#:
class Class1
    {
        protected string value = "to be overwritten";
        public Class1(string convert)
        {
            value = convert;
        }
    }

    class Class2 : Class1
    {
        public Class2(string additional, string convert)
            : base(convert)
        {
            value = convert + additional;
        }
        public string value { get; set; }
    }

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Class2 test = new Class2(" additional text", "original text");
            label1.Text = test.value;
        }
    }

I2S プロトコル

I²S(Inter-IC Sound)は、マイコンやオーディオ機器間で音声データをやり取りするために設計された、シリアル通信プロトコルです。I²CやSPIと名前は似ていますが、I²Sは音声専用のプロトコルです。 I²Sは、以下の3つの主要な信号線を使って通信します。 BCLK (...