none
Is an array of predefined data type? RRS feed

  • Question

  • Hi

    I know c# has Array class that is individually so

    I want to know this is true that array is predefined reference type?




    • Edited by Reza1992 Wednesday, February 26, 2020 4:36 AM
    Wednesday, February 26, 2020 4:35 AM

Answers

  • Hi Reza1992, 
    I afraid that the array is not predefined reference type.
    Predefined Data types are those that a programming language natively supports. Such as int, float, char, double.
    User Defined Data types are those that are structured by users i.e. programmers for the sake of convenience such as array, you don't have any data type in C where you can store a list of integer elements, other examples include queue, stack.
    C# includes some predefined value types and reference types.
    Value types: byte,sbyte,short,ushort,int,uint,long,ulong,float,double,decimal,char,bool,DateTime.
    Reference types: object,string.
    More details you can refer to this document.
    [C# - Data Types]
    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, February 26, 2020 6:42 AM

All replies

  • An array is class that has its own properties and methods. A class is a type by OO definition. 

    https://docs.microsoft.com/en-us/dotnet/api/system.array?view=netframework-4.8

    Everything in .NET C# or VB is derived from the base class from an OO standpoint.

    https://docs.microsoft.com/en-us/dotnet/api/system.object?view=netframework-4.8

    Wednesday, February 26, 2020 6:33 AM
  • Hi Reza1992, 
    I afraid that the array is not predefined reference type.
    Predefined Data types are those that a programming language natively supports. Such as int, float, char, double.
    User Defined Data types are those that are structured by users i.e. programmers for the sake of convenience such as array, you don't have any data type in C where you can store a list of integer elements, other examples include queue, stack.
    C# includes some predefined value types and reference types.
    Value types: byte,sbyte,short,ushort,int,uint,long,ulong,float,double,decimal,char,bool,DateTime.
    Reference types: object,string.
    More details you can refer to this document.
    [C# - Data Types]
    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, February 26, 2020 6:42 AM
  • I think you didn't get it right my question: is this true array is predefined?(or false is user defined)
    Wednesday, February 26, 2020 6:42 AM
  • Yeah array is user defined type thanks a lot

    Daniel_Zhang-MSFT





    • Edited by Reza1992 Wednesday, February 26, 2020 7:01 AM
    Wednesday, February 26, 2020 6:52 AM
  • hi

    Array is a class in c# ,Some function of the class is described bellow

    using System;
    
    class Program
    {
       static void Main(string[] args)
            {
                string[] names = {"Jane", "Frank", "Alice", "Tom" };
                string[] girls = new string[5];
    
                Array.Sort(names);
    
                foreach(string el in names)
                {
                    Console.Write(el + " ");
                }
    
                Console.Write('\n');
    
                Array.Reverse(names);
    
                foreach(string el in names)
                {
                    Console.Write(el + " ");
                }
    
                Console.Write('\n');
                 Array.Copy(names, girls, names.Length);
    
                foreach(string girl in girls)
                {
                    Console.Write(girl + " ");
                }
                Console.Write('\n');
    
                Array.Clear(names, 0, 2);
    
                foreach(string name in names)
                {
                    Console.Write(name + " ");
                }
    
    
            }
    }

    Wednesday, February 26, 2020 6:58 AM
  • array is an object type of base type System.Array elements can be of any type, including an array type. Array types are reference types which are derived from the abstract base type Array. These types implement IEnumerable and for it, they use foreach iteration on all arrays in C#
    Wednesday, February 26, 2020 7:35 AM