I can"t gain my head approximately this. I know void way it doesn"t return anything, but what walk that typical exactly? to me, the WriteLine method takes a string and prints it to the screen.
You are watching: What does public static void mean
Please assist me understand the various varieties of methods.
You"re right that the "WriteLine method takes a string and prints it come the screen". Yet think about that because that a moment, after that prints come the screen, the returns manage to the ar in the regimen where it to be called. However it does not give ago a value. Therefore the return form is "void" (nothing). That doesn"t typical that it does nothing, it just returns nothing.
On the various other hand the ReadLine technique returns a string. As soon as it returns to the caller, it provides this string back as the an outcome of call it.
Does that make feeling now?
And all of this is completely unrelated to "static", that"s something rather entirely. Static way that there"s only among them, friend don"t need an circumstances to access it, and also all instances (if any) will share the same one.
babasariffodeen 6,475 clues
babasariffodeen 6,475 points
July 11, 2016 5:19pm
Hmm, i am sort of understanding it. Would certainly you please have the ability to give me examples of a technique that returns something? I have the right to perhaps gain a better understanding by method of contrast. And maybe something number in nature? i think the strings are confusing me.
Steven Parker 210,507 point out
Steven Parker 210,507 point out
July 11, 2016 5:47pm
Returning number or strings is really similar, however here"s an instance with a number. The Count technique returns how countless things room in one iterable. For this reason for instance if you had actually a repertoire of flowers, you might use it to discover out huge the arsenal was, choose this:
int howmany = flowers.Count(); // the Count() technique returns the number of items
In this case, howmany is gift assigned to the value returned by Count. If Count to be void, there would be naught to entrust (and the explain would cause a compiler error).
Ranbir sink 1,566 point out
Ranbir singh 1,566 clues
September 14, 2016 10:45pm
There space two species of methods, course methods that belongs come the class (Static) and also other one belonging to instance of the class.in stimulate to contact Static technique You need to write the surname of the class followed through a period and then method name conversely, non static techniques which are circumstances methods of the class are dubbed or invoked using instance or object of the class.
The example below : I created a class names Example, which contains two methods Static an approach which is StaticMethod() and also non static an approach NonStaticMethod();
Now to use them in the code I create an an additional class called Program with key Method
first create an object of the class Example ex = brand-new Example();then usage object to call the method
to contact static method you simply need to compose the name of course i.e Example.StaticMethod();
public class Example public revolution void StaticMethod() // perform something;
puclic void NonStaticMethod() //do something.
public course Programe public static void Main()
instance ex = brand-new Example(); //create an instance or thing of instance class// execute or call non static an approach using an item ex of Example class ex.NonStaticMethod(); //now execute Static an approach using class name Example.StaticMethod();
Lee Owen 7,907 point out
Lee Owen 7,907 clues
may 26, 2018 3:48pm
A yes, really simple means of thinking about void methods vs no void methods is prefer asking a girlfriend to do something.
You can ask them come say what time that is and they can just to speak it out loud and also that"s the finish of it, which would be a void method.
A no void technique would be similar to if you were to ask a friend what time it is so that you could take the time and tell that to another friend so the he could tell you if he has actually anything reserved for that time on his calendar.
If you watch the static keyword it method that over there is only one circumstances of it, and I"m sure that will acquire covered an ext in depth later on on.
See more: Can You Substitute Diced Tomatoes For Crushed Tomatoes, The 5 Best Substitutes For Crushed Tomatoes
Robert Gioeli 667 points
Robert Gioeli 667 point out
October 16, 2018 6:57pm
You would think they might just make C# recognize when there is something to return at this allude or not lol
Posting come the forum is only allowed for members with energetic accounts. Please authorize in or authorize up come post.
See complete Catalogue
Terms & Conditions|Privacy
© 2021 Treehouse Island, Inc.