Skip to content

Inheritance problem

Nath

Asked Apr 18, 2006, 8:25 AM EDT1 answer
Share
LinkedInX

Why won't this code work?

using

System;

using

System.Windows.Forms;

namespace

Practice
C#
{
class Practice
{
public static void Main()
{

// declare and assign a string variable called human
string human;
human = "Walking & talking life";

// declare and assign an int variable called mind
int mind;
mind = 100;

// Print the value of the variables to the console
Console.WriteLine(mind);
Console.WriteLine(human);

}
}

class Continued
{
public static void notMain()
{
MessageBox.Show(human);
MessageBox.Show(mind);

}

}
}

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • +1

    u can try in this manner the inharitance



    using System;

    using System.Windows.Forms;

    namespace Practice

    {

    class Practice

    {

    // declare and assign a string variable called human

    public string human;

    public int mind;

    public Practice()

    {

    human = "Walking & talking life";

     

    // declare and assign an int variable called mind

     

     

    mind = 100;

     

     

    // Print the value of the variables to the console

    Console.WriteLine(mind);

    Console.WriteLine(human);

    }

    }

     

    class Continue:Practice

    {

    public static void Main()

    {

    Practice a = new Practice();

    MessageBox.Show(a.human);

     

    }

     

    }

    }

    +1