✅ splitting project into multiple files
ive never done this before so im not sure where to begin. i am working on something and would like to split some features into multiple projects, i just dont know how. thank you!
35 Replies
Your title and your text dont seem to align.
The title speaks of splitting a single project into multiple files.
The text speaks of splitting features into multiple projects.
What exactly are you trying to do, and what is your current codebase like?
i guess splitting it into features is what i want to do
i would like to have some features split into multiple cs files
so everything isnt all cluttered
Right.
How do you define a feature, currently?
i just have one cs file with all my code
i am gonna start working on another thing but would preferably do it somewhere else, while still being part of the same project
Okay
Can you show me your current code?
oh, so its all just one giant method?
for the time being, yeah
Okay.
So step 1, lets split this ping thing into its a new method in a new class
so we separate our entrypoint from the ping
good idea
So make a new .cs file, maybe "PingCommand.cs"?
alr
done
ok, and was there also a class created in that file?
yes
great. so lets make a new method in that class to host our code
public static void Run(string[] args)
should do the trickalright
done
now, lets cut all our code from
GodyPing.cs
public static void Main
method into your new methoddone
finally, lets make
Main
call the new method
PingCommand.Run(args);
done
try running your program
okay, lets see the build errors
ahh
i think i know why
do i have to paste all the libraries into that new file?
it is telling me it doesnt know what 'Ping' is
you mean the
using ...
statements?
yeahyes
alr
i see a few errors i can fix
Looks like your main method was async in your original file
so you'll need to make the new one async too
public async Task Run(string[] args)
still saying 'Ping' doesn't contain a definition for 'Send'
then
Ping
isnt the same ping as it was before
Its a bit hard to troubleshoot this without actually seeing the code. Do you want to screenshare?sure, what call do you want to get in to?
#dev-vc-1
ty 😄
You can
/close
the thread if you don't have any further questions.it says i dont have permission