C#基本语法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudentCShrap
{
    class RectTest
    {

        public double m_length;
        private double m_width;
        private double GetArea()
        {
            return m_width * m_length;
        }

        public void AccepetDetails()
        {
            m_length = 4.5;
            m_width = 4.2; 
        }
        public void DisPlay()
        {
            Console.WriteLine("length: {0}", m_length);
            Console.WriteLine("width: {0}", m_width);
            Console.WriteLine("Area: {0}", GetArea());
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudentCShrap
{
    class MainClassTest
    {
        static void Main(string[] args)
        {
            RectTest r = new RectTest();
            r.AccepetDetails();
            r.DisPlay();
            Console.WriteLine("{0}", r.m_length);
            Console.ReadKey();
            
        }
    }
}

成员变量

  1. 成员变量默认为 私有属性 ,可以强行改成公有等属性
  2. 成员变量是类的属性或者数据成员,用来存储数据的

成员函数

  1. 执行一系列指定操作的函数
  2. 类的成员函数在类内申明

标识符

  1. 标识符是用来识别类 函数 变量 或者其他用户定义的项目
  2. 标识符必须以字母下划线 或者@开头,可以在后面跟一系列字母数字下划线 @ 
  3. 标识符的第一个字符不能是数字
  4. 标识符必须不包含任何嵌入的空格或者符号 比如 ?》《*&……%¥#!
  5. 标识符不能是C#的关键字,除非在前面加上@前缀
  6. 标识符区分大小写
  7. 不能与C#的类库同名

关键字

 

  1. 保留关键字

    1. abstrac
    2. as
    3. base
    4. bool
    5. break
    6. byte
    7. case
    8. catch
    9. char
    10. checked
    11. class
    12. const
    13. continue
    14. decimal
    15. default
    16. delegate
    17. do
    18. double
    19. else
    20. enum
    21. event
    22. explicit
    23. extern
    24. false
    25. finally
    26. fixed
    27. float
    28. for
    29. foreach
    30. goto
    31. if
    32. implicit
    33. in
    34. int
    35. interface
    36. is
    37. lock
    38. long
    39. namespace
    40. new
    41. null
    42. operator
    43. out
    44. override
    45. params
    46. private
    47. protected
    48. public
    49. readonly
    50. ref
    51. return
    52. sbyte
    53. sealed
    54. short
    55. sizeof
    56. stackalloc
    57. static
    58. string
    59. struct
    60. switch
    61. this
    62. throw
    63. true
    64. try
    65. typeof
    66. uint
    67. ulong
    68. unchecked
    69. unsafe
    70. ushort
    71. using
    72. virtual
    73. void
    74. volatile
    75. while
  2. 上下文关键字

    1. add
    2. alias
    3. ascending
    4. descending
    5. dynamic
    6. from
    7. get
    8. global
    9. group
    10. into
    11. join
    12. let
    13. orderby
    14. partial (type)
    15. parital (method)
    16. remove
    17. select
    18. set
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值