c# - Error: "an object reference is required for the non-static field, method or property..." -
Creating an application on ImC #. To accomplish its work, if there is a prime and if the same swap number is the prime, when I create my solution on the visual studio, then it says that "an object reference is required for non-static field, law or property Is ... "Im" volteado "and" siprimo "with methods to deal with this problem. Can you tell me where the problem is and how can I fix it? Thanks!
Namespace console application 1 {class program {static zero main (string [] arg) {console.light ("write number:"); Long A = Convert ToInt64 (Console.Readline ()); // A, the number given by the user is AV = Voltage (A); // AVI is "A" but if swap is done (Sipparomo (A) == incorrect & amp; amp; amp; nbsp; (AV) == wrong) console Wrightite ("Both original and swap numbers are prominent."); Else console. The light line ("one of the numbers is not prominent."); Console.ReadLine (); } Private Bull Scipomo (Long A) {// Evaluate that the number received is the principal bull SP = true; For (tall k = 2; k & lt; = a / 2; k ++) if (a% k == 0) sp = false; Return SP; } Private long voltage (long A) {// received number long V = 0 swap; While (A & gt; 0) {v = 10 * v + a% 10; A / = 10; } Return V; }}}}
You can not access non-static members with a static method Are there. (Note that is the main () which requires the net.) Keeping the keyword stable before them, just make the Siparomo and Voltage stable. Eg: Fixed Private Long Voltage (Long A)
Comments
Post a Comment