✅ Im kinda new to c# and I don't know how to use the new function...
I'm trying to make an object with a new() function but I keep getting "Member modifier 'new' must precede the member type and name". I'm using public void new()
19 Replies
$details
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
You can't name a method 'new' it is a reserved name
oh then how do I use it? im trying to make it so you can use it like new Sprite(stuff here)
Use a class
im using a class
Please post the code
ok
ofc i cant write anything in the function bc the function wont even work
use the constructor
can you explain
Constructors - C# programming guide - C#
A constructor in C# is called when a class or struct is created. Use constructors to set defaults, limit instantiation, and write flexible, easy-to-read code.
This can 🙂
OOH
That allows you to do exactly what you want.
so this?
Correct
tysm for responding so quickly
Anytime.
i literally have to go in 30 mins
:>