C
C#7mo ago
hensoro

How do these parameters even work?

I have a project where I need to transfer information from my GUI's textbox and turn it into an average(census) but I have to do it from a class file. Our professor gave us this method with parameters and told me to pass the information but i don't know how and its messing up my code.
No description
5 Replies
𝗝𝗮𝗺𝗲𝘀
@Hensoro , can you provide the compilation error? Also, it would be really nice to elaborate more on the question, some more details can really matter getting an accurate response
Nefario
Nefario7mo ago
you can think parameter as of the key, and the method is the house with different set of lock. as long as you know the what lock is, you can create that key.
public void foo(int lock1, string lock2){}
public void foo(int lock1, string lock2){}
if you want to call the method it means you need to call it for specific lock
foo(12345,"test");
foo(12345,"test");
also if you have to call a method from a class you can think of this class as the owner of this house, for example if you have avarage class
public class Devin
{
public void foo(int lock1, string lock2){}
}
public class Devin
{
public void foo(int lock1, string lock2){}
}
Devin dev = new Devin();
dev.foo(123,"test");
Devin dev = new Devin();
dev.foo(123,"test");
of course each owner have different personality, you can think of avarege class = introvert so you need to make a relatioshop first (we always call this create a new object). and if the class is static like below you can think of it as extrovert person. just call it by name and he always reply to you
public static class bar2{}
public static class bar2{}
hensoro
hensoroOP7mo ago
sure, The question is what is the purpose of the convert 32 in the parameters and is there a way to call on it in my method?
No description
No description
𝗝𝗮𝗺𝗲𝘀
There are a lot of problems in this code. I think you should refollow it with your professor in order to understand it's purpose. It's hard to understand from here why is text being passed to an int parameter (that's why there is a convert there, txtNumBaths.Text is a string! ProcessHouse receives an int HouseNum) also, the compilation error is referring to a value for a parameter that's missing, it was probably forgotten and must be provided to call the method.
hensoro
hensoroOP7mo ago
Thats kinda what im confused about is if i dont need to refer to the .text then how will i refrence it in my code do i just put NumBaths as is? i tried asking my professor and he was like vague which is confusing me more Like i thought that the parameters would be some kind of variable that i can plug into the method but idk how to do that
Want results from more Discord servers?
Add your server