❔ ✅ CS0116 [SOLVED]
and CS1061: 'Form1' does not contain a definition for 'button1_Click' and no accessible extension method 'button1_Click' accepting a first argument of type 'Form1' could be found (are you missing a using directive or a assembly reference?)
I'm just making a installer and i'm a C# beginner so I don't know how to fix this
22 Replies
Methods go into classes
Classes go into namespaces
Seems like your titular error is because some of your methods have been placed in a namespace
This is sus in particular
Make sure you format your code properly so you can see where each class and method starts and ends
$prettycode
To format your code in Visual Studio, Visual Studio Code, Rider, use the following shortcut:
NOTE: the first key must be held while doing it.
https://cdn.discordapp.com/attachments/569261465463160900/899513918567890944/2021-10-18_01-26-35.gif
I restarted VS 2019 and Main.Designer.cs changed
so whats a methof
d
A function
i just followed this tutorial then this happened
https://www.youtube.com/watch?v=n5jDXRDg070
DM Velocity
YouTube
C# WinForm UI - Round Rect / Ellipse Button
This tutorial is to teach you how to make an ellipse button in C# without 3rd party app.
#UIDesign #CSharp #Button
For more videos please go to my channel:
https://www.youtube.com/channel/UCCViFHnPq_IQV5eQTbjVu1A
Music: https://www.youtube.com/watch?v=B7xai5u_tnk&list=RDMMcMg8KaMdDYo&index=2
how do i know if the thing im looking at is a function
$structure
For C# versions older than 10, see
$StructureOld
Here's the basic structore of a C# file
i dont understand 💀
Which part?
$StructureOld i think i have an older version of C#
For C# versions from 10 onwards, see
$structure
idfk man maybe both
This example shows most of what can be in a file, but not everything has to be there
The stripped down version would be
So, in short, make sure that
- Your class is within the namespaces braces (
{}
) or make sure the namespace is file-scoped, so ends with a semicolon (;
) and doesn't have braces
- All your methods are within the class's braces
Prettyinfying your code will help you see whether or not everything is correct
It's easier to spot the error when your code isn't
but
instead
You immediately see you have one }
too manywell deleting that } solved the problem
thanks
cs0161 is also fixed
$close
Use the /close command to mark a forum thread as answered
didnt know there was a close command
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.