Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 132,359 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,216 people online right now. Registration is fast and FREE... Join Now!




Pointer help in C#

 
Reply to this topicStart new topic

Pointer help in C#

jacobjordan
post 28 Aug, 2008 - 04:40 PM
Post #1


class Me : Perfection

Group Icon
Joined: 11 Jun, 2008
Posts: 1,105



Thanked 22 times

Dream Kudos: 1575
My Contributions


Here's my problem. I have this line of code in an unsafe context:
csharp

TreeNode* Current = null;

it gives me an error that says "Cannot take the address of, get the size of, or declare a pointer to a managed type ("System.Windows.Forms.TreeNode")"
The C++ equivalent of that line would be
cpp

System::Windows::Forms::TreeNode *Current = 0;

and in C++, i can avoid that error by using the '^' operator like so
cpp

System::Windows::Forms::TreeNode^ *Current = 0;

however, i know little to nothing about C++, and i have no idea what the '^' operator does. If anyone knows a way to implement this in C#, please let me know.
User is offlineProfile CardPM

Go to the top of the page

knightyknight
post 6 Sep, 2008 - 04:20 AM
Post #2


New D.I.C Head

*
Joined: 6 Sep, 2008
Posts: 5


My Contributions


As far as I know you can only declare pointers to base types such as int and byte that might be why.
User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 6 Sep, 2008 - 05:56 AM
Post #3


Working Girl.

Group Icon
Joined: 6 Feb, 2008
Posts: 5,402



Thanked 94 times

Dream Kudos: 2625

Expert In: Dingleberries

My Contributions


You're right, you can only have a pointer to base types and arrays in C#

[click]

What is it that you're aiming to do? It's most likely possible without a pointer.

smile.gif
User is offlineProfile CardPM

Go to the top of the page

jacobjordan
post 6 Sep, 2008 - 02:52 PM
Post #4


class Me : Perfection

Group Icon
Joined: 11 Jun, 2008
Posts: 1,105



Thanked 22 times

Dream Kudos: 1575
My Contributions


I was aiming to load a treeview from an XML file format i made. However, i have since found a way to do this without a pointer, so this question's ancient history.

However, i'm still clueless on what the '^' operator does when declaring a variable in C++ like System::Windows::Forms::Form^ Whatever;. Anyone care to enlighten me?

This post has been edited by jacobjordan: 6 Sep, 2008 - 02:53 PM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 04:31AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month