Jump to content
Xtreme .Net Talk

Recommended Posts

  • Administrators
Posted

you mean a constructor that uses unsafe code (pointers and such like)?

 

The following should do the trick - you will also need to modify the project properties to allow unsafe code.

public class Class1
{
	public Class1()
	{
		unsafe
		{
		char * str;
		}
	}
}

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted (edited)

I got it to work but found that I cannot pass pointers to managed types, which makes sense.

 

The reason I was trying to use pointers was that I cannot assign a class to a class.

Here is the edit method:

void Edit()
{
if(this.surface.selWB==null)
	return;

a.graphics.WrappedBmp wb=new a.graphics.WrappedBmp(this.surface.selWB);
EditForm f=new EditForm(this.surface, ref wb);
if(DialogResult.Yes==f.ShowDialog())
{
	this.surface.selWB= wb;
	this.surface.Invalidate();
	this.needsSaved=true;
}
f.Dispose();
}

In EditForm f, wb is directly modified and IS actually changed, HOWEVER, when I assign

this.surface.selWB= wb;

selWB does NOT change. There are no errors, just nothing!

 

But if when I initialize wb like this:

a.graphics.WrappedBmp wb= this.surface.selWB;

this.surface.selWB IS changed from the EditForm. And is what I don't want. I want a new instance of WrappedBitmap to be directly changed and then assign that to this.surface.selWB only if EditForm returns Yes.

 

Why doesn't wb when it is a new instance and modified by EditForm change selWB when it is assigned to it?? ie..

the full code above.

Edited by aewarnick
C#
Posted

Ok, got somewhere but don't really understand why the above does not work.

 

Here is what I had to do:

I created a method in Class WrappedBmp called Assign.

 

When I call that and send wb to it, it works.

 

Why doesn't the above code work?

C#

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...