Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 11th, 2006, 08:21 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
Default Problem with returning value from class library

Hi,

I want get return value from a class and call it from the main programming, 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.Format6 4bppPArgb);

                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();


 
Old September 11th, 2006, 08:50 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Your class is called ScanFirstStage and so is one of its methods. This is not allowed, try calling the method Scan or something similar. ScanFirstStage is a strange name for a class, if you are following Microsoft guidelines then classes should be noun or noun phrases, Scanner, for example.

http://msdn.microsoft.com/library/de...guidelines.asp

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem retrieving data processed by class library maricar C# 0 October 23rd, 2008 10:27 PM
Using a class library Kiran Patil VS.NET 2002/2003 0 August 19th, 2006 05:52 AM
Regarding Class Library (.dll) from class file manish.sharma04 BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 March 3rd, 2006 07:32 AM
Class Library ~Bean~ ASP.NET 1.x and 2.0 Application Design 3 October 17th, 2005 07:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.