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.
- How to get Synchronize access to the Array in C#
- How to get Synchronize access to the Queue in C#
- C# | How to get Synchronize access to the ArrayList
- How to get Synchronize access to the Stack in C#
- How to get Synchronize access to the ListDictionary in C#
- How to get Synchronize access to the StringCollection in C#
- How to get Synchronize access to the HybridDictionary in C#
- How to get Synchronize access to the StringDictionary in C#
- Access Modifiers in C#
- Difference between Class and Structure in C#
- Range Structure in C# 8.0
- C# | Copy the elements of collection over a range of elements in ArrayList
- 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
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.