C
C#14mo ago
Yuvi

❔ CS7036 Error in Visual Studio. Simple Console Webshop program.

https://paste.mod.gg/ametaivrdggr/0 - Code I can't figure out why I can't call SignInScreen()
BlazeBin - ametaivrdggr
A tool for sharing your source code with the world!
No description
8 Replies
Angius
Angius14mo ago
Well it's quite clear, isn't it? SignInScreen() takes four parameters You call SignInScreen() with zero parameters
Yuvi
YuviOP14mo ago
I tried copying all the parameters as well before, didn't make a difference but gave me 10x errors. Can you show me a corrected example? Because for me, it isn't quite clear unfortunately.
Angius
Angius14mo ago
If a method takes parameters, method must get parameters
public string GetSum(int a, int b)
{
return $"Sum of {a} and {b} is {a + b}";
}

string result;
result = GetSum(); // bad
result = GetSum(10, 2); // good
public string GetSum(int a, int b)
{
return $"Sum of {a} and {b} is {a + b}";
}

string result;
result = GetSum(); // bad
result = GetSum(10, 2); // good
So, see if you even need those parameters From what I can see in your code, you don't use any of them in the method
Yuvi
YuviOP14mo ago
Oh I left them there for future use, ah well to remove it for now Thanks I think I get it now
ZacharyPatten
ZacharyPatten14mo ago
btw don't use Convert.ToInt32. use int.Parse or (preferably) int.TryParse instead. You can directly replace Convert.ToInt32 with int.Parse so you should do that, but in order to use int.TryParse you would have to make a few additional changes also you can replace
Console.WriteLine(" --------- \n Login Screen \n ---------");
Console.WriteLine(" 1. Sign up \n 2. Sign in \n 3. Exit");
Console.WriteLine(" Note: Enter the number to choose" +
"your function throughout the program");
Console.Write(" Choose your function: ");
Console.WriteLine(" --------- \n Login Screen \n ---------");
Console.WriteLine(" 1. Sign up \n 2. Sign in \n 3. Exit");
Console.WriteLine(" Note: Enter the number to choose" +
"your function throughout the program");
Console.Write(" Choose your function: ");
with
Console.Write("""
---------
Login Screen
---------

1. Sign up
2. Sign in
3. Exit

Note: Enter the number to choose your function throughout the program

Choose your function:
""");
Console.Write("""
---------
Login Screen
---------

1. Sign up
2. Sign in
3. Exit

Note: Enter the number to choose your function throughout the program

Choose your function:
""");
much cleaner in my opinion
Yuvi
YuviOP14mo ago
Holy shiiiii that seems so useful I dont think I ended up fixing anything, uh Im getting more confused Can someone show me a corrected example of this just so I can understand where I went wrong Been stuck here for a while uhh
Angius
Angius14mo ago
This method
static void SignInScreen(string name, string password, string phoneNumber, string email)
static void SignInScreen(string name, string password, string phoneNumber, string email)
takes four parameters Here you call this method
else if (loginInput == "2")
SignInScreen();
else if (loginInput == "2")
SignInScreen();
but you give it zero parameters
Accord
Accord14mo 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.
Want results from more Discord servers?
Add your server