Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the c # structure

Shulou Source: shulou.com Published: 2022-06-03 05:53:14 10月01日 Update

This article mainly explains "how to use c # structure". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the c # structure.

Look directly at C++ and c # code:

Struct structpointer {int id; int* ptrid;}; void processstructpointer (structpointer * sp) {if (sp = = NULL) return; int* p; p = sp- > ptrid; while (true) {if (* p! = 0) / / process {cout ptrid = p as long as it is not 0 / / notice how to write processstructpointer (pt); processstructpointer (pt);}

Note: the phenomenon of calling processtructpointer (pt) twice in a row:

1) when ids [0] = 1; ids [1] = 5; ids [2] = 0, then all phenomena are normal OK

2) when ids [0] = 1; ids [1] = 5; ids [2] = 7, then all phenomena are incorrect.

The above two phenomena are easy to understand, the key is the structure, structure pointers, structure members are pointers, structure pointers as parameters between C++ and c # how to deal with. In fact, there is also IntPtr that can handle struct-related parameters.

Supplementary note:

In the past, the experiment has always been that the name of struct in C++ and c # is the same. Today, the above structpointer is changed to structpointerxback, and other c # code is changed accordingly. As a result, the experiment is also OK. This shows that the name is just a form, really from the memory point of view, C++ processing is not in terms of the name, or from the physical structure of memory.

At this point, I believe you have a deeper understanding of "how to use the c # structure". 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!

Tags: Structures caches names phenomena caches pointers processing memory content parameters addresses expressions statements learning experiments practical deeper between code key Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux NVidia Shulou Technology Docker macOS