How to declare c++ pointer in C#
BIRDREADING *bird_data;
bird_data = &frame.reading[i];
How to declare such in C#?
update1:
i want To call a C++ DLL/lib or to rewrite in C#. Actually i try to solve my own question on this link.Use a variable directly(data return are same in an array) or with pointer? T开发者_如何学Cry my luck to solve the question after i convert above into c#
In c# you can declare pointers which called as unsafe programming.
Example :
unsafe {
int iData = 10;
int* pData = &iData;
Console.WriteLine("Data is " + iData);
Console.WriteLine("Address is " + (int)pData );
}
Check this article : Writing Unsafe code using C#
type* identifier;
It depends, will BIRDREADING be a reference type?
You can't declare pointers to reference types from Pointer Types (C#)
Any of the following types may be a pointer type:
sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal, or bool.
Any enum type.
Any pointer type.
Any user-defined struct type that contains fields of unmanaged types only.
So for your example, giving that BIRDREADING statisifies the above
BIRDREADING *bird_data;
Also, what do you want to use the pointer for? Are you sure you need a pointer?
If BIRDREADING
is a class it is a pointer by definition and you don't need to do anything special:
BIRDREADING bird_data;
bird_data = frame.reading[i];
If it's a struct then getting its poiner depends on the context.
精彩评论