C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2722
Number of posts: 5749

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
return value from class Posted by labby on 11 Sept 2006 at 4:50 AM
Hi,

I want get return value from a class and call it from the main programming code, but it return error. The error is :

ScanFirstStage: members name cannot be same as their enclosing type.
Could any help me please?

This is the class that suppose return the value -->

public int ScanFirstStage (Bitmap image, out int cb)
{

// get image size
int width = image.Width;
int height = image.Height;

pixels = width * height;
// lock bitmap data
BitmapData imgData = image.LockBits(
new Rectangle(0, 0, width, height),
ImageLockMode.ReadOnly,
PixelFormat.Format64bppPArgb);

int srcStride = imgData.Stride;
int srcOffset = srcStride - width;


// do the job
unsafe

{
byte* p = (byte*)imgData.Scan0.ToPointer();
int i = 0;

for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
if (*p == 0)
{
i++;
}

++p;
}

p += srcOffset;
}

cb = i;
}

// unlock image data
image.UnlockBits(imgData);

}

This is the code from mainform to call the return value -->

ClassFirstStage.ScanFirstStage filter3 = new ClassFirstStage.ScanFirstStage(binary, out scanning1);
//apply filter for extraction
double scan1 = filter3.ScanFirstStage;
int num1 = (int)scan1;
objectCount1.Text = num1.ToString();

Report
Re: return value from class Posted by Gogi on 17 Sept 2006 at 7:45 AM
: Hi,
:
: I want get return value from a class and call it from the main programming code, but it return error. The error is :
:
: ScanFirstStage: members name cannot be same as their enclosing type.
: Could any help me please?
:
: This is the class that suppose return the value -->
:
: public int ScanFirstStage (Bitmap image, out int cb)
: {
:
: // get image size
: int width = image.Width;
: int height = image.Height;
:
: pixels = width * height;
: // lock bitmap data
: BitmapData imgData = image.LockBits(
: new Rectangle(0, 0, width, height),
: ImageLockMode.ReadOnly,
: PixelFormat.Format64bppPArgb);
:
: int srcStride = imgData.Stride;
: int srcOffset = srcStride - width;
:
:
: // do the job
: unsafe
:
: {
: byte* p = (byte*)imgData.Scan0.ToPointer();
: int i = 0;
:
: for (int y = 0; y < height; y++)
: {
: for (int x = 0; x < width; x++)
: {
: if (*p == 0)
: {
: i++;
: }
:
: ++p;
: }
:
: p += srcOffset;
: }
:
: cb = i;
: }
:
: // unlock image data
: image.UnlockBits(imgData);
:
: }
:
: This is the code from mainform to call the return value -->
:
: ClassFirstStage.ScanFirstStage filter3 = new ClassFirstStage.ScanFirstStage(binary, out scanning1);
: //apply filter for extraction
: double scan1 = filter3.ScanFirstStage;
: int num1 = (int)scan1;
: objectCount1.Text = num1.ToString();
:
:


Hello,

Seems like you have a class and a function in that class which have the same names.
Example:
You have class ScanFirstStage and function ScanFirstStage in that class.

I hope it helps!

Greetings from Gogi



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.