static void Main(string[] args) { StaticTest2.Foo(); StaticTest2.Some(); StaticTest.Foo(); Console.ReadLine(); }
private void button1_Click(object sender, EventArgs e) { StaticTest test = new StaticTest(); test.FileName = txtFileName.Text; test.MaxScores = txtMaxScores.Text; Variable[] vars = new Variable[dgVars.Rows.Count]; int cnt = 0; foreach (DataGridViewRow dgvr in dgVars.Rows) { string name = dgvr.Cells[0].Value + ""; if (!name.Equals("")) { vars[cnt] = new Variable(); vars[cnt].Name = name; vars[cnt].DataType = dgvr.Cells[1].Value + ""; vars[cnt].Score = Int32.Parse(dgvr.Cells[2].Value + ""); vars[cnt].ErrMsg = dgvr.Cells[3].Value + ""; cnt++; } } test.Vars = vars; cnt = 0; Statement[] stmts = new Statement[dgStmts.Rows.Count]; foreach (DataGridViewRow dgvr in dgStmts.Rows) { string type = dgvr.Cells[0].Value + ""; if (!type.Equals("")) { stmts[cnt] = new Statement(); stmts[cnt].Type = type; stmts[cnt].Score = dgvr.Cells[1].Value + ""; stmts[cnt].ErrMsg = dgvr.Cells[2].Value + ""; cnt++; } } test.Stmts = stmts; Exceptions ex = new Exceptions(); Check []checks = new Check[dgExceptions.Rows.Count]; cnt = 0; foreach (DataGridViewRow dgvr in dgExceptions.Rows) { string type = dgvr.Cells[0].Value + ""; if (!type.Equals("")) { checks[cnt] = new Check(); checks[cnt].Type = type; checks[cnt].Count = dgvr.Cells[1].Value + ""; checks[cnt].Statement = dgvr.Cells[2].Value + ""; checks[cnt].Score = dgvr.Cells[3].Value + ""; checks[cnt].ErrMsg = dgvr.Cells[4].Value + ""; } } ex.Checks = checks; test.Ex = new Exceptions[] { ex }; TestSuiteDB.saveStaticTest(test); MessageBox.Show("Static Check Saved Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); }
public void StaticMethod() { var x = new StaticTest { InnerValue = 3, CachedValue = 3 }; RoundTrip(x); }
static void Main(string[] args) { // int x22; StaticTest st = new StaticTest(10, 23); st.SimplePrint(); //st.StaticPrint(); //静态方法不能使用实例来调用 StaticTest.StaticPrint(); Console.ReadLine(); }
/// <summary> /// static 関数、static プロパティを使う /// </summary> static void Static01() { Console.WriteLine(StaticTest.Pi); int[] numbers = { 5, 3, 2, 6, 9, 10 }; int sum = StaticTest.Sum(numbers); // static な関数はインスタンスを作るのではなく「クラス名.関数」で呼び出す Console.WriteLine(sum); // static なプロパティは「各インスタンスに依存しない」値を返すことができる StaticTest st1 = new StaticTest(), st2 = new StaticTest(), st3 = new StaticTest(); Console.WriteLine("StaticTest クラスのインスタンスは {0} 個あります", StaticTest.count); /* * ここで以下をやってみましょう * https://paiza.jp/works/cs/primer/beginner-cs7/21007/1 * */ }
void Start() { instance = this; obj = GameObject.CreatePrimitive(PrimitiveType.Cube); // 从下面的测试可以看出:本场景中的存在的静态物体或非静态物体,切换到另一场景后是回收的 // 除非挂载不销毁的物体上 //obj.transform.SetParent(this.transform); obj2 = GameObject.CreatePrimitive(PrimitiveType.Cube); //obj2.transform.SetParent(this.transform); // 下面是超级重点: // 静态对象是随着类的加载而加载的 : 即这个类只要创建出来了,不管有没有继承 MonoBehaviour 或者 挂在游戏对象上 // 静态对象的值都已经加载上了,即被赋值了,在内存的静态区; // 所以上面数据中:当本类没有继承MonoBehaviour时, instance =null ;obj =null ;value =5;value3 =0 // 而其余非静态对象,则都没有赋值 : value2 obj2 timer // 当这个类继承了 MonoBehaviour 或者挂在了游戏对象上,静态值还是不改变的,除非重新赋值 value3 = 15; //DontDestroyOnLoad(this); }
public static void CallStatic() => StaticTest?.Invoke();
void Start() { StaticTest myTest = new StaticTest(); myTest.IncrementScore(); }
public List <String> GetTest() { return(StaticTest.GetStrings()); }
public String GetTestAdd(String test) { StaticTest.Add(test); return("Added:" + test); }
private static void AfterDeserializationMethod(StaticTest o) { o.CachedValue = o.InnerValue; }
private void Start() { StaticTest stest = new StaticTest(); IncrementScore(); }
public static void saveStaticTest(StaticTest chk) { TestSuiteDB.scheck = chk; }