C
C#9mo ago
Öland

How do i share variables from 1 script onto another with VS

So say i have 2 script in a directory and the first script wants to print the amount of fuel you have left but the only way to access how much fuel you have left is by running the second script. How could you take the variable from the second one and use it in the first one?
1 Reply
Angius
Angius9mo ago
There's no such thing as a "script" in C# You can access members of one class in another by just... referring to it
// Program.cs
MyCoolHelper.Help();
// Program.cs
MyCoolHelper.Help();
// MyCoolHelper.cs
public static class MyCoolHelper
{
public void Help()
{
Console.WriteLine("I am helping");
}
}
// MyCoolHelper.cs
public static class MyCoolHelper
{
public void Help()
{
Console.WriteLine("I am helping");
}
}
Want results from more Discord servers?
Add your server