Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Partial class problem in c# : not possible to invoke a method correctly

I’m new to c# and just started studying the partial classes topic.
Made some practice but I dont understand why when I do run a programm the console stamps only the method from the 1st partial class and completely ignores the second partial class when I’m invoking the "AndAgainDoSomething()" method.

Maybe it’s because in can not open second console without closing the first one ?

public interface ISomething
    {

    }

    public partial class MyInterface : ISomething
    {
        public void DoSomething()
        {
            //some stuff
            Console.WriteLine("Thats pt1 of what my partial class is doing ");
            Console.ReadLine();
        }
    }

    public partial class MyInterface
    {
        public int MyProperty { get; set; }
        public int MyProperty1 { get; set; }

        public void AndAgainDoSomething()
        {
            Console.WriteLine("Thats pt2 of what my partial class is doing ");
            Console.ReadLine();
        }
    }


    class Program
    {
        static void Main(string[] args)
        {
            var firstPart = new MyInterface();
            firstPart.DoSomething();
            firstPart.AndAgainDoSomething();

        }
    }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

After the Console.WriteLine in DoSomething, there is a Console.ReadLine, so you need to press Enter for the code to move on and execute the second method?

Have you added breakpoints and stepped through in the debugger to see where the code is stopping?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading