What is the difference between a class and a datat

2019-04-05 07:35发布

I have heard the following statement:

We can say class is a datatype or a datatype is one type of class.

Can anyone explain to me what exactly this means?

10条回答
Viruses.
2楼-- · 2019-04-05 08:10

All (or almost) all programming languages have a notion of a datatype. A datatype can be things like: Integers, doubles, booleans etc.

C# and other languages allow us to define our own "custom" datatypes. That's where classes come in. Custom datatypes in OO languages are called classes and when we define such classes it is the type definition or type.

Take a look at this Wikipedia page for more information

查看更多
闹够了就滚
3楼-- · 2019-04-05 08:16

A class is a data type. A datatype is a concept, it's not a class. That is to say, you look at something and say to yourself "Hmm yes, that is so-and-so type of data", or "That is this datatype". Then you say "Specifically, the datatype is List<..>", and so on.

查看更多
对你真心纯属浪费
4楼-- · 2019-04-05 08:19

A class is a type of a data type. It allows you to declare a variable along with its datatype. E.g.:

class big  
{  
    public int a;  
    .......  
    ......    
}    

Here, int is a data type and big is the class name.

Hope you got little idea about it!

查看更多
叛逆
5楼-- · 2019-04-05 08:24

class is a object oriented programming concept, and datatype is generic to all programming paradigm. Class is a datatype but datatype are not class

查看更多
Lonely孤独者°
6楼-- · 2019-04-05 08:24

This article from the MSDN might be of some use in this regard. It tries to explain what Objects, Classes and Structs are in terms of C#.

查看更多
放荡不羁爱自由
7楼-- · 2019-04-05 08:27

a class is a data type if a user creates a class, it is known as user defined data-type.

查看更多
登录 后发表回答