Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

C # basic data type classification

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "C# basic data type classification". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn the "C# basic data type classification"!

The value type in the C# basic data type stores its data content directly, while the reference type stores the reference of the object. These two types have different meanings to the assignment of variables.

Value types include: simple type, structure type, enumeration type; reference type includes: Object type, class type, interface, representative element, string type, array.

C # basic data type-example of value type

Int m = 0 × int n = m * * m = 1; / / at this time n is still 0, because the data of m and n are stored in different regional reference type examples

Class CFoo {public int n;}

Void Main () {CFoo F1 = new CFoo (); f1.n = 0; CFoo f2 = F1; f1.n = 1; / / at this time f2.n becomes 1, because the contents of f2 and F1 are of the same address} value type

The value types are: byte (1), sbyte (1), short (2), ushort (2), int (4), uint (4), long (8), ulong (8), float (4), double (8), decimal (8), char, bool, enumeration, structure.

The numbers in parentheses above indicate the number of bytes. Byte, ushort, uint, ulong are unsigned types (no negative numbers). By the way, sbyte is signed bytes.

These types are aliases for the .NET Framework type aliases, as indicated by String and string.

C # basic data type-reference type

Reference types are: object type, class type, interface, representative element, string type, array.

Although the string type (string) is a reference type, Microsoft overloaded some of these operators to make it easier for us to design, making it apply as if it were a value type.

At this point, I believe you have a deeper understanding of the "C# basic data type classification". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report