C#基本数据类型 和数据结构

本文详细介绍了C#编程语言中的基本数据类型,包括整型、浮点型、布尔型、字符型等,并深入探讨了C#中的数据结构,如数组、列表和字典的使用方法及其在实际编程中的应用。通过阅读,读者将能够掌握C#中数据类型的选用和数据结构的实现技巧。
摘要由CSDN通过智能技术生成
using System;
using System.Collections.Generic;
using System.Text;

namespace LeetCode2019
{
    public static class Basic
    {

        public static void BasicDataStructure()
        {
            //Primitive data types
            bool myBool = true;
            byte myByte = 101; // 0 - 255
            sbyte mySbyte = 1; // -128 to 127
            char myChar = 'a'; //U+0000 to U+FFFF
            decimal myDecimal = 300.5m;  //±1.0 x 10(-28) to ±7.9228 x 10(+28)
            double myDouble = 33.4d;
            float myFloat = 33.44f;
            int myInt = -5;
            uint myUInt = 5;
            long myLong = 1000000000000;
            ulong myULong = 1000000;
            object myObject = new object();
            short myShort = 255;       //-32,768 to 32,767	 Signed 16-bit integer
            ushort myUShort = 32776;    //0 to 65,535       Unsigned 16-bit integer
            string myString = "abc";


            //Array :https://www.geeksforgeeks.org/c-sharp-arrays/
            //Syntax:
            //<Data Type>[] <Name_Array> = new <datatype> [size];
            int[] intArray1 = new int[5]; //default value is 0
            int[] intArray2 = new int[5] { 1, 2, 3, 4, 5 };
            int[] intArray3 = { 1, 2, 3, 4, 5 };

            for (int i = 0; i < intArray1.Length; i++)
            {
                Console.WriteLine(intArray1[i]);
            }

            //Multidimensional Arrays, (Rectangular Array)
            int[,] intArray2D = new int[4, 2];  //two dimensional array
            int[,,] intArray3D = new int[4, 2, 3]; // three dimensional array


            
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值