C#的数据结构

变量类型

  1. 值类型

    1. bool   布尔型
    2. btye    8位无符号整数 0x00~0xff
    3. char    16位无符号整数
    4. decimal 128位精确的10进制值
    5. double    64位
    6. float       32 位
    7. int           32位
    8. long        64位
    9. sbyte     8位有符号
    10. short      16位
    11. uint       32位无符号
    12. ulong    64位无符号
    13. ushort   16位无符号 

           sizeof 可以获取变量的位数

  1. 引用类型
    1. 引用类型不包含存储在变量中的值,引用类型指向内存位置
    2. 内置的引用类型有 object dynamic string
    3. 对象类型
    4. 动态类型
      1. 可以存储任何类型的值到变量中,在运行时生效
    5. 字符串类型
      1. String str= “Helloworld“;
      2. 加引导字符@ ,可以把字符串中的 ‘\'字符看待  @"\\HelloWorld"  == “\HelloWorld”
      3. 字符串可以任意换行,空格键和换行符都算在字符串长度之内
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;
        
        namespace StudentCShrap
        {
            class MainClassTest
            {
                static void Main(string[] args)
                {
                    String str = "Helloworld\n\n\n";
                    Console.WriteLine(str.Length);//13 length
                    str = @"12345897522
                            4152454
                                524154";
                    Console.WriteLine(str.Length);//72 length
                    
        
        
                    Console.ReadKey();
                    
                }
            }
        }
        

         

  2. 指针类型
    1. 存储另一种类型的内存地址 跟C和C++的指针有相同的作用
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      
      namespace StudentCShrap
      {
          class MainClassTest
          {
              static void Main(string[] args)
              {
                  int* Leng; //错误 CS0214: 指针和固定大小缓冲区只能在不安全的上下文中使用
                  Console.ReadKey();
                  
              }
          }
      }
      

       

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值