unsafe constructor?

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.
C#:
	public class Class1
	{
		public Class1()
		{
			unsafe
			{
			char * str;
			}
		}
	}
 
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:
C#:
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.
 
Last edited:
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?
 
Back
Top