Hello!
I have a method in a public class
static void Input ()
{
// Coding here
}
and I was wondering if it is possible for me to call that static method over to another class.
I tried this:
Input inp = new Input( );
inp.Start();
but it doesn't seem to work (The type or namespace name "Input" could not be found).

Ramesh MaruthiRank #937 · 2.2K reputationPosted Oct 14, 2014, 5:53 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Oct 14, 2014, 8:09 PM EDT
Hi,
The static member (methods, fields, properties, or events) is callable on a class even when no instance of the class has been created. The static member is always accessed by the class name, not the instance name. Only one copy of a static member exists, regardless of how many instances of the class are created.
you have to use
Input.Start();
hope this will help you.
Ramesh MaruthiRank #937 · 2.2K reputationPosted Oct 14, 2014, 2:35 PM EDT
Rajeev RanjanRank #373 · 6.8K reputationPosted Oct 14, 2014, 8:43 PM EDT
Static member gets called when the instance of the class is created, and it is accessed by the class name rather then creating object and "object.InstanceName".
Try to call directly
Song Lee49 reputationPosted Oct 15, 2014, 11:24 AM EDT
I got it now~! XD
Song Lee49 reputationPosted Oct 14, 2014, 4:05 PM EDT
public class Input
{
static double fromF;
public void Start()
{
FirstInput();
}
static void FirstInput()
{
Console.Write("Enter number : ");
double.TryParse(Console.ReadLine(), out fromF);
}
///////////////////////////////////////////////////////////////////////////
I need this method called to another class.
it's so~ confusing because i am not sure if Static void FirstInput() needs to be double or string.
Ramesh MaruthiRank #937 · 2.2K reputationPosted Oct 15, 2014, 11:26 AM EDT