473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Inheritance

BRawn
28
I'm having a bit of an issue inheriting from a class. I'm taking code from an old VB.NET app and writing it in C#. I have a public class which only consists of 2 fields, a constructor and 2 properties.

I need to inherit a generic list object which isn't a problem, but my environment doesn't see the class from which it must inherit.

Class: MyClass

Expand|Select|Wrap|Line Numbers
  1.  
  2.             public class MyClass
  3.     {
  4.  
  5.         #region /// FIELDS ///
  6.  
  7.         string columnName;
  8.         string format;
  9.  
  10.         #endregion
  11.  
  12.         #region /// CONSTRUCTORS ///
  13.  
  14.         public MyClass()
  15.         {
  16.             columnName = "";
  17.             format = "";
  18.         }
  19.  
  20.         public MyClass(string fieldName, string formatString)
  21.         {
  22.             columnName = fieldName;
  23.             format = formatString;
  24.         }
  25.  
  26.         #endregion
  27.  
  28.         #region /// PROPERTIES ///
  29.  
  30.         public string ColumnName
  31.         { get; set; }
  32.  
  33.         public string Format
  34.         { get; set; }
  35.  
  36.         #endregion
  37.  
  38.     }
  39.  
  40.  





When I try to inherit MyClass from my Collection object, I can't...
What I want to do is:






Expand|Select|Wrap|Line Numbers
  1.  
  2. public class Collections : List<MyClass>
  3.  
  4.  



In VB.NET, the code looks like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Class Collections
  3.     Inherits List(Of MyClass)
  4.  
  5.     Public Sub New()
  6.         MyBase.New()
  7.     End Sub
  8.  
  9. End Class
  10.  
  11.  


How can I achieve the same result in C#?
Jul 24 '12 #1
1 1394
BRawn
28
Nevermind, found the problem.
The classes are in different folders in the solution (not solution folders, standard folders) and each folder is seen as on object. I had to reference the folder that my MyClass was in before the Collections class would recognize it
Jul 24 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
5
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should...
10
by: davidrubin | last post by:
Structural inheritance (inheriting implementation) is equivalent to composition in that a particular method must either call 'Base::foo' or invoke 'base.foo'. Apparantly, The Literature tells us to...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
6
by: Bart Simpson | last post by:
I remember reading on parashift recently, that "Composition is for code reuse, inheritance is for flexibility" see (http://www.parashift.com/c++-faq-lite/smalltalk.html#faq-30.4) This confused...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.