Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 March 7th, 2007, 05:29 AM
Authorized User
 
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vijaykumartaduri Send a message via Yahoo to vijaykumartaduri
Default Please give me the solution to my example.

class MyClassA {
}

class MyClassB
{
    void MyMeth() {
    }
}

class MyClassC
{
}

class MyTest {

    public static void Main(){
        MyClassA A;
        MyClassB B;
        MyClassC C;
        dothis(A);
        dothis(B);
        dothis(C);
    }

    void dothis(Object o) {
        o.MyMeth();
    }
}

Will above example compile and execute? If not pls give me the resone and solution.

Thanks,
Vijay Kumar Taduri
__________________
Thanks,
Vijay Kumar Taduri
 
Old March 7th, 2007, 06:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

The method executed inside dothis(object o) must be a method of object.
To correct this you need to have a interface or a base class that impliments MyMeth.

public class MyBase
{
private void MyMeth()
{
//code here
}

}
public class MyClassA:MyBase{}

class MyTest {

    public static void Main(){
        MyClassA A;
        MyClassB B;
        MyClassC C;
        dothis(A);
    }

    void dothis(MyBase o) {
        o.MyMeth();
    }
}


======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
 
Old March 7th, 2007, 06:36 AM
Authorized User
 
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vijaykumartaduri Send a message via Yahoo to vijaykumartaduri
Default

Let tell me will it compile fine?
Pls give me the exact answer once you execute.


Thanks,
Vijay Kumar Taduri
 
Old March 7th, 2007, 09:17 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Do your own homework.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old March 7th, 2007, 11:41 PM
Authorized User
 
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vijaykumartaduri Send a message via Yahoo to vijaykumartaduri
Default


I Will....

Quote:
quote:Originally posted by dparsons
 Do your own homework.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
Thanks,
Vijay Kumar Taduri





Similar Threads
Thread Thread Starter Forum Replies Last Post
Please give me solution deepak.deemca C++ Programming 1 October 17th, 2007 04:27 PM
give me solution asudhakar ASP.NET 1.0 and 1.1 Basics 2 March 19th, 2007 09:33 AM
hi expert! Can u give me solution for this???? jasdeephere ASP.NET 1.0 and 1.1 Professional 1 February 10th, 2007 02:16 AM
What is wrong in following code?Give me solution [email protected] Pro VB.NET 2002/2003 1 September 19th, 2006 04:49 PM
CROSS_TAB,,, RTL problem, Plz Give me solution raza_mrk36 Crystal Reports 0 April 4th, 2006 02:33 AM





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