Inheritance

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BRawn
    New Member
    • Jul 2010
    • 28

    Inheritance

    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

    Code:
                public class MyClass
        {
    
            #region /// FIELDS ///
    
            string columnName;
            string format;
    
            #endregion
    
            #region /// CONSTRUCTORS ///
    
            public MyClass()
            {
                columnName = "";
                format = "";
            }
    
            public MyClass(string fieldName, string formatString)
            {
                columnName = fieldName;
                format = formatString;
            }
    
            #endregion
    
            #region /// PROPERTIES ///
    
            public string ColumnName
            { get; set; }
    
            public string Format
            { get; set; }
    
            #endregion
    
        }





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






    Code:
    public class Collections : List<MyClass>



    In VB.NET, the code looks like this:

    Code:
    Public Class Collections
        Inherits List(Of MyClass)
    
        Public Sub New()
            MyBase.New()
        End Sub
    
    End Class


    How can I achieve the same result in C#?
  • BRawn
    New Member
    • Jul 2010
    • 28

    #2
    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

    Comment

    Working...