Make the console take a value from another class in C #

2

I'm trying to learn C # language. In this case I'm trying to make the Console show the value of the balance, taking this value from a different class in the same file (already tried with multi-files and still does not work, the compiler does not see the variable). >

using System;
using namespaceb;

namespace namespaceb
{
    public class saldo
    {
       public int numero = 100;
    }
}

namespace namespacea
{
    class Program
    {
        static void Main(string[] args)
        {
            saldo teste = new saldo();
            Console.WriteLine(numero); //dá erro "O nome Numero não existe no contexto atual"
            Console.WriteLine(teste); // mostra uma linha "namespaceb.saldo"
            Console.ReadKey();
        }
    }
}
    
asked by anonymous 08.03.2018 / 18:23

1 answer

2
using System;
using namespaceb;

namespace namespaceb
{
    public class saldo
    {
       public int numero = 100;
    }

    class Program
    {
        static void Main(string[] args)
        {
            saldo teste = new saldo();
            Console.WriteLine(teste.numero);
            Console.ReadKey();
        }
    }
}
    
08.03.2018 / 22:44