none
Abstract class RRS feed

  • Question

  • Hi all,

    I have a already implemented static class to add company details.Now I want to generalize that class.(i.e. not only for company, for anything) So I try to implement that class as an Abstract one. Is it possible to create that implementing class as static? The abstract class cannot be difine as static. Please help

    Wednesday, April 27, 2011 6:24 AM

Answers

  • No. Implementing class cannot be declared static. Scenario you are narrating seems for me to be against OOPS principles. May be you may make some of your base/derived class methods as static. Note that static class can derive only from "object" (which is the default base class for all .net classes)
    - Rajesh K http://thoughtsontechies.blogspot.com/
    • Marked as answer by Creative_Pro Wednesday, April 27, 2011 6:51 AM
    Wednesday, April 27, 2011 6:32 AM

All replies

  • No. Implementing class cannot be declared static. Scenario you are narrating seems for me to be against OOPS principles. May be you may make some of your base/derived class methods as static. Note that static class can derive only from "object" (which is the default base class for all .net classes)
    - Rajesh K http://thoughtsontechies.blogspot.com/
    • Marked as answer by Creative_Pro Wednesday, April 27, 2011 6:51 AM
    Wednesday, April 27, 2011 6:32 AM
  • If you say you are implemented a static class then you are already generalized as it doesn't belongs to any particular instance. But I guess you have implemented it with hardcode reference of company details. You can remove the dependency of the company details from that class and pass necessary information to class, so it will be generalized. Or else you no need of static class. Use a normal class and do the factoring.
    Wednesday, April 27, 2011 6:55 AM
  • Hi Albin,

    Yes the problem is as you mentioned above. I have hardcoded some company details. I will try to pass those values as parameters.Thank you very much.

    regards

    Anu

    Wednesday, April 27, 2011 7:05 AM