标签:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace ClassTrining 7 { 8 public class MyTestClass 9 { 10 /// <summary> 11 /// 12 /// </summary> 13 public bool _isTrue = true; 14 /// <summary> 15 /// 16 /// </summary> 17 public bool IsTrue 18 { 19 get 20 { 21 return _isTrue; 22 } 23 set 24 { 25 _isTrue = value; 26 } 27 } 28 29 public static void Test() 30 { 31 } 32 } 33 34 internal class 运算符 35 { 36 public void TestA() 37 { 38 //成员运算符 . 用于调用类的成员 39 MyTestClass.Test(); 40 41 MyTestClass myTest = new MyTestClass(); 42 //三目运算符,如果myTest._isTrue为真,str取值为true,如果myTest._isTrue为假,str取值为false 43 var str = myTest._isTrue ? "true" : "false"; 44 45 int a = 1; 46 int b = 2; 47 //加法运算 48 int c = a + b; 49 //减法运算 50 int d = c - a; 51 //乘法运算 52 int e = a * c; 53 //除法运算 54 int f = c / a; 55 //求余运算(求c除b的后余数,如 3 % 2 = 1,3除2的余数为1) 56 int g = c % b; 57 58 //自增1 59 a++; 60 //自减1 61 a--; 62 63 64 } 65 } 66 }
标签:
原文地址:http://www.cnblogs.com/linhongquan/p/5470644.html