❔ method
Hello,
If I create a method, does the method know about things in the Main method? Or am I supposed to tell the method?
P
Pobiega•407d ago
it will not "know" about things in other methods
P
palekf•407d ago
how to tell
P
Pobiega•407d ago
you'll get compilation errors? 🙂
P
palekf•407d ago
how to import a int/string in a other method
D
Doombox•407d ago
public void DoThing(string someValue){ }
pass what you want to use in the method as a parameterE
ero•407d ago
arguments
P
palekf•407d ago
thank you @Ero @Task.WhenAll
P
Pobiega•407d ago
E
ero•407d ago
they meant "how to tell the method about the variable"
not "how to tell that it doesn't work"
P
Pobiega•407d ago
P
palekf•407d ago
thank you too
E
ero•407d ago
what are those warnings though
P
Pobiega•407d ago
suggestions (var over int, public could be private). Not relevant to the topic.
also, chill with the passive aggressive comments while someone is helping lol
E
ero•407d ago
what?
what passive aggressive comments
P
Pobiega•407d ago
E
ero•407d ago
yeah that's just
fact
and clarification
P
Pobiega•407d ago
Read the initial post.
I think its a good idea to show the initial state and how to fix the problem
E
ero•407d ago
what
P
palekf•407d ago
static public int Poop(string countPoopString) {
try {
int countPoopInt = Int16.Parse(countPoopString);
}
catch {
Console.WriteLine("Konverting dont available");
}
return countPoopInt ;
}
T
TheRanger•407d ago
$code
M
MODiX•407d ago
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/T
TheRanger•407d ago
odd method name there
P
palekf•407d ago
where
T
TheRanger•407d ago
u called ur method
Poop
P
palekf•407d ago
yes
T
TheRanger•407d ago
which means this 💩
P
palekf•407d ago
and?
its dor testing
for
T
TheRanger•407d ago
so im saying its odd, u asked where
P
palekf•407d ago
what means odd
P
Pobiega•407d ago
weird, unusual
anyways, your code has a problem.. you are declaring a variable in the try that might not succeed.
countPoopInt
is declared in the wrong "scope" for you to use it as the returnP
palekf•407d ago
what do you mean with scope
P
Pobiega•407d ago
$scopes
M
MODiX•407d ago
thing a
is available in scope A
and scope B
thing b
is available only in scope B
P
Pobiega•407d ago
anywhere you see
{
, that creates a new scope
}
closes the current scope
so the stuff inside the try is not availble outside itP
palekf•407d ago
so how to get it outside
P
Pobiega•407d ago
You could split the declaration and the assignment
so you declare the variable outside the try, and assign to it inside.
you'll need to give it a default value thou, in case the try fails
P
palekf•407d ago
P
Pobiega•407d ago
better, but you have duplicate declarations now
T
TheRanger•407d ago
Int16 btw
P
Pobiega•407d ago
Ah yes, don't use that. just
int.Parse
insteadP
palekf•407d ago
ok
T
TheRanger•407d ago
P
palekf•407d ago
that I know, but the parse is not recocnized now
T
TheRanger•407d ago
how so?
u need to tell us what error messages u see
and show us ur current code
P
palekf•407d ago
the name "int" isnt there in the actual konext
T
TheRanger•407d ago
copy paste the error message
P
palekf•407d ago
Im a german so the error message is in german
T
TheRanger•407d ago
doesnt matter, i can see the error code number
P
palekf•407d ago
CS0103
T
TheRanger•407d ago
error message can help too since it can tell which variable it has the issue with
and show ur current code
P
palekf•407d ago
ok wait
T
TheRanger•407d ago
its
int.Parse(countPoopString);
not Int.Parse(countPoopString);
i is smallP
palekf•407d ago
oh
yeah
Ill be away for a short time, thank you
A
Accord•406d ago
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.We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
51KMembers
View on DiscordWant results from more Discord servers?
More Posts❔ Project structure1. In my Solution there should be only 1 Project right? Unless its a big App
2. I started using fo❔ how to use EF6 in library with no dependancy injection and no startup.csI used EF core power tools to generate DB Context and reverse engineer the models.
now I get an erro❔ HeadFirst Design PatternSo I started with this Book today. First problem starts with the Duck Project:
and when he tests h✅ EqualityComparerHello, anyone know of this code work ?
--> `EqualityComparer<ICollection<myclass>> .Default.Equals❔ error attaching script (unity)this error appears when trying to attach the script, does anyone know how to solve it?❔ i have an app that runs well on my pc but not on other pcsi have an app that runs well on my pc but on when i zip it and bring it to another pc the ui is all yield???```cs
public IEnumerable<int> A()
{
for (int i = 0; i <= 10; i += 2)
yield return i;
}
C# Data Table issuehttps://pastebin.com/DSHwSh0M
based on this program, I need to set the values of the `Old PS A11Y S❔ Microsoft Graph SDK - Serializing objectsHello,
I am currently working with Microsoft Graph API to work with the Planner. My goal is to backu❔ XML deserialise different types into a single listI'm using the build in XML serialisation library (unless it's with .NET framework?), and I current h❔ Access things from different scene in UnityI have a Class Selector scene that has a Class Selector Script component (MonoBehaviour) attached to❔ C# how do I write an If-statement to handle a button?Hi, I wanted some assistance with writing a If-statement that filters out the zones section in my ap❔ Magnetic Links for application?Hey, does someone have an article/tutorial/explanation how I can develop magnetic links for my appli❔ Show values from a list in a datagridview getting source from bindingsourceHello! I have the following problem: I am currently developing a winforms app with a datagridview th❔ Render email content .NET 7 (razor)I have to reinplement email content rendering, because currently its not looking really good, especi❔ GetAxis wont workpublic class Driver : MonoBehaviour
{
// Start is called before the first frame update
const✅ (SOLVED)Help a Beginneri am following CodeMonkeys 11Hr youtube video on coding a game in unity. I have ran into a issue whe❔ Exclude items from linq query if they contain one from an array of substringsI've got a list of strings, that if they appear anywhere in a linq query column i want to exclude th✅ Comprehension questions (LeetCode Binary Search)Like the title says it's about this puzzle https://leetcode.com/problems/binary-search/description/
❔ How to create a cubic function calculator that also calculates the minimum and maximum value```c
Console.WriteLine("Please enter a, b, c, d for the cubic function ax^3+bx^2+cx+d");