Can someone help me with passing values from one class method to another in c#. I've tried looking it up, but I get lost in pages of code and I cant find a simple example. Take a look at the following:
//Main Program Program.cs
namespace simplecode
{
class Program
{
static void Main(string[] args)
{
Values Values = new Values();
Values.getName();
}
}
}
//Separate class file or object Values.cs
namespace simplecode
{
public class Values
{
public static void getName()
{
Console.Clear();
Console.Write("Enter name: ");
string myName = Console.ReadLine();
}
}
}
Now, if I execute this the main program runs getName and I can store the myName variable. How do I grab the value of myName from the main program, or another separate class method? Im trying to understand this conceptually and I need the proper syntax. If someone could explain whats needed or provide a study link id appreciate it.
Thanks Mike