locked
nest classes or structs inside a dll RRS feed

  • Question

  • hey,

    i currently build a dll and encounter a problem. If i build an class with methods inside, the hosting project will display the mthods in intel sense. That works, but how i can nestet functions, that intel sense display a division after a prevously. i try to nest one class in an other, but then intelsense display nothing from the second than, causes i can not initilaize an object of the second class.

    How edfault dll´s are build to display nested function with the whitepaper-symbol and the yellow sign on the right head??????????

    Wednesday, January 12, 2011 9:26 PM

Answers

  • // DLL Program
    
    namespace LibCSharpClass
    {
      public class OuterClass1
      {
        public InnerClass1 objinnerClass;
    
        public OuterClass1()
        {
          objinnerClass = new InnerClass1();
        }
    
        public class InnerClass1
        {
          public void Verify(string input)
          {
            Console.Write(input);
          }
        }
      }
    }
    
    

    Calller:

    using LibCSharpClass;
    
    namespace TestLibCSharpClass
    {
      class Program
      {
        static void Main(string[] args)
        {
          MyClass myClass = new MyClass();
          Console.ReadKey();
        }
      }
    
      class MyClass
      {
        OuterClass1 objOuterClass = new OuterClass1();
        
        public MyClass()
        {
          objOuterClass.objinnerClass.Verify("myString");
          //OuterClass1.InnerClass1 innerClass = new OuterClass1.InnerClass1(); => You can Access the inner class this way as well.
        }
      }
    }
    
    
    
    After looking at your implementation I could see the above possibilities.
    Santosh.
    • Marked as answer by Bin-ze Zhao Wednesday, January 19, 2011 8:09 AM
    Thursday, January 13, 2011 4:29 AM

All replies

  • Since you did not post code of your "nested" class, I will venture a guess.  Declare the nested class as public.


    Mark the best replies as answers. "Fooling computers since 1971."

    http://rudedog2.spaces.live.com/default.aspx

    Wednesday, January 12, 2011 10:57 PM
    Moderator
  • namespace

     

     

    AudioTags

    {

     

     

    public class Mp3Tags

    {

     

     

    public class Attributes

    {

     

     

     

    /// <summary>Verifies if a Title Tag exists. If a Title Tag exists the method returns 1, if not the returnvalue is 0.

     

     

    /// <param name="path">Path to an audiofile, represented as a string.</param>

     

     

    /// </summary>

     

     

    public void VerifiesTitle(string path)

    {

    }

    }

    }

    }

    ................

     

    Thats athe maincode of my dll. I try, cuased of the inner class, that IntelSense (if i referenced the assemblx) show me the method

    VerifiesTitle only, if i write following:  Mp3Tags tags = new Mp3Tags(); tags.Attributes.VerifiesTitle(). But i doesn´t work. I get some hints now, that i must implement properties (get & set) to reach something like this, but how can a properites nested another elements?? So i try to do so with classes....

    Do you have any ideas????

    Wednesday, January 12, 2011 11:11 PM
  • This link has VB.NET code, but it shows how to read the tags.  There are many translators available on the web.

    Playing with Music Files

     


    Mark the best replies as answers. "Fooling computers since 1971."

    http://rudedog2.spaces.live.com/default.aspx

    Wednesday, January 12, 2011 11:32 PM
    Moderator
  • // DLL Program
    
    namespace LibCSharpClass
    {
      public class OuterClass1
      {
        public InnerClass1 objinnerClass;
    
        public OuterClass1()
        {
          objinnerClass = new InnerClass1();
        }
    
        public class InnerClass1
        {
          public void Verify(string input)
          {
            Console.Write(input);
          }
        }
      }
    }
    
    

    Calller:

    using LibCSharpClass;
    
    namespace TestLibCSharpClass
    {
      class Program
      {
        static void Main(string[] args)
        {
          MyClass myClass = new MyClass();
          Console.ReadKey();
        }
      }
    
      class MyClass
      {
        OuterClass1 objOuterClass = new OuterClass1();
        
        public MyClass()
        {
          objOuterClass.objinnerClass.Verify("myString");
          //OuterClass1.InnerClass1 innerClass = new OuterClass1.InnerClass1(); => You can Access the inner class this way as well.
        }
      }
    }
    
    
    
    After looking at your implementation I could see the above possibilities.
    Santosh.
    • Marked as answer by Bin-ze Zhao Wednesday, January 19, 2011 8:09 AM
    Thursday, January 13, 2011 4:29 AM