I'm trying to figure out simply pass arguments from one constructor to another. In this case I want to know how to pass the parameters int protons,int electrons from class Atom to my derived class called hydrogen where my constructor is. Right now I'm currently using int,int in my derived constructor inside of Hydrogen which seems to be incorrect.
using System;
public class Atom
{
public Atom (int protons, int electrons)
{
Protons = protons;
Electrons = electrons;
}
public int Protons { get; set; }
public int Electrons { get; set; }
public void Send()
{
Console.WriteLine(Protons);
Console.WriteLine(Electrons);
}
}
public class Hydrogen : Atom
{
public Hydrogen() : base(int, int) { } <!--This is the line that is wrong -->
}
public class Program
{
public static void Main()
{
var hydrogen = new Hydrogen();
hydrogen.Send();
}
}
I would like the above code to compile but I'm getting an error in my derived class where I'm passing through int, int next to the : base. I've tried passing through protons and electrons but that doesn't compile either.