Check some possible issues:
- A static constructor must be parameterless.
- Memeber names can not be the same as their enclosing type.
- Properties: best set Android API 8 or higher.
- What IDE do you use - maybe here is the problem? (Recommended VS2010)
- Do you have the newest dot42 installed, with all the necessary licence and security keys?
I have VS2010 and the newest dot42 plugin installed on Win7 OS, and tried to simulate your class expecting to see the same errors, however everything compiled good. The simulated static class is put in another file, in the same namespace. I call its static methods from another class elsewhere - MainActivity class.
Here is the simulated class:
using System;
using Android.App;
using Android.Os;
using Android.Widget;
using Dot42;
//using Dot42.Manifest;
namespace MyNamespace
{
public class CRC8
{
static byte[] table = new byte[256];
//x8 + x2 + x + 1
const byte poly = 0x07;
public static byte getCRC(byte[] _bytes)
{ return _bytes[0];
}
public static byte getCRC(String str_bytes)
{ return (byte) str_bytes.CharAt(0);
}
static CRC8()
{
//nothing happens so far
}
}
}
Here is the call within MainActivity class:
protected override void OnCreate(Bundle savedInstance)
{
base.OnCreate(savedInstance);
SetContentView(R.Layouts.MainLayout);
TextView text_view = (TextView)FindViewById(R.Ids.textView1);
byte[] aa = { 125, 54, 67, 78, 89 };
byte b_ret = 0;
b_ret = CRC8.getCRC("Ala ma kota");
text_view.Text += "CRC8.getCRC(String): " + b_ret.ToString() + "\n";
b_ret = CRC8.getCRC(aa);
text_view.Text += "CRC8.getCRC(byte[]): " + b_ret.ToString() + "\n";
text_view.Text += "CRC8.getCRC(ASCII.GetBytes): ";
text_view.Text += CRC8.getCRC(System.Text.Encoding.ASCII.GetBytes("ABC123XYZ")).ToString() + "\n";
}
Here is the output (API 18 i.e. Android 4.3):
- CRC8.getCRC(String): 65
- CRC8.getCRC(byte[]): 125
- CRC8.getCRC(ASCII.GetBytes): 65
Can you find any difference between our codes and so on? I hope this helps.