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

How to use the c # structure

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

Share

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

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!

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