Working with pointers - getting strange error message -- please help!

A

almurph

Hi,

I'm getting the error: "{ expected" under the "int" when I'm using
pointers in C#. The code is very simple as shown below:

***** CODE *****

private void button1_Click_1(object sender, EventArgs e)
{
unsafe int *p;

}


Anyone with any ideas/comments/suggestions - all would be most
appreciated.

Thanks,
Al.
 
A

almurph

Hi Al,

thats what you want and is syntactically right:

        private void button1_Click_1(object sender, EventArgs e)
        {
            unsafe
            {
                int* p;
            }
        }

See here:

[C# Language Reference
unsafe (C# Reference)]http://msdn.microsoft.com/en-us/library/chfa2zb8.aspx

And this if you like:

[Writing Unsafe code using C#]http://www.codeproject.com/KB/cs/unsafe.aspx

Regards

Kerem

--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project:http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects:http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."



I'm getting the error: "{ expected" under the "int" when I'm using
pointers in C#. The code is very simple as shown below:
***** CODE *****
private void button1_Click_1(object sender, EventArgs e)
{
unsafe int *p;

Anyone with any ideas/comments/suggestions - all would be most
appreciated.
Thanks,
Al.- Hide quoted text -

- Show quoted text -

Thanks Kerem - its working now. However I'm getting the error
"Identifier expected" with the following code:

unsafe
{
int[] *a;
}

Any ideas?
Confused, Al.
 
K

Kerem Gümrükcü

Hi Al,

this is not a valid construct. What exactly are you trying to do?
Explain the problem, we may find a apropriate solution,...


Regards

Kerem

--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

Hi Al,

thats what you want and is syntactically right:

private void button1_Click_1(object sender, EventArgs e)
{
unsafe
{
int* p;
}
}

See here:

[C# Language Reference
unsafe (C#
Reference)]http://msdn.microsoft.com/en-us/library/chfa2zb8.aspx

And this if you like:

[Writing Unsafe code using
C#]http://www.codeproject.com/KB/cs/unsafe.aspx

Regards

Kerem

--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project:http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects:http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

Newsbeitrag

I'm getting the error: "{ expected" under the "int" when I'm using
pointers in C#. The code is very simple as shown below:
***** CODE *****
private void button1_Click_1(object sender, EventArgs e)
{
unsafe int *p;

Anyone with any ideas/comments/suggestions - all would be most
appreciated.
Thanks,
Al.- Hide quoted text -

- Show quoted text -

Thanks Kerem - its working now. However I'm getting the error
"Identifier expected" with the following code:

unsafe
{
int[] *a;
}

Any ideas?
Confused, Al.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top