Unlike C/C++, Structures in C# can have members that are methods, fields, indexers, operator methods, properties or events. The members can have access specifiers as public, private, and internal.
Pointers are variables that store the addresses of the same type of variable i.e. an int pointer can store an address of an integer, a char pointer can store an address of a char and similarly for all other data types, fundamental or user-defined.
You can access a structure member using pointers, of type structure, in the following ways;
1) Using the arrow operator: If the members of the structure are public then you can directly access them using the arrow operator ( -> ). If they are private then you can define methods for accessing the values and use pointers to access the methods. The arrow operator can be used to access structure variables as well as methods.
2) Using Dereferencing operator: You can also access structure elements using the dereferencing operator on the pointer, which is using an asterisk to dereference the pointer and then using the dot operator to specify the structure element.
Note: To compile unsafe code on Visual Studio (2012), Go to Project –> ProjectName Properties –> Build –> Check the “Allow unsafe code” box.
- C# | Remove all elements in a collection from a HashSet
- C# | How to get the Remaining Elements of the Tuple?
- C# | Get the number of elements actually contained in the ArrayList
- C# | Check if SortedSet and a specified collection share common elements
- C# | Check if HashSet and the specified collection contain the same elements
- C# | Check if a HashSet and a specified collection share common elements
- C# | Number of elements in HashSet
- C# | Get the number of elements contained in the Stack
- C# | Get the number of elements contained in the Queue
- C# | Remove all elements from the Hashtable
- C# | Remove all elements from a HashSet
- C# | Check if SortedSet and the specified collection contain the same elements
- C# | Removing all the elements from the List
- C# | Count the total number of elements in the List
- C# | Copying the elements of ArrayList to a new array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.