24 Replies
U mean how to declare a method?
yea
so like idk where to put the new mothod
bc it gives a error when i make it
Can I see the code?
yes
how dod i send it in that format every1 uses
wait nvm its ok
using System;
using System.Net;
namespace Learning_Cs
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a username: ");
string UserName = Console.ReadLine();
if (UserName.Length >= 3)
{
Console.WriteLine("Thats a short name");
}else
{
Console.WriteLine("Welcome in " + UserName);
}
} } } so my goal is to make a method that loops asking for a username thats bigger than 3 letters
} } } so my goal is to make a method that loops asking for a username thats bigger than 3 letters
U can use do loop
not yet
still learing it
learning*
So
its in the vid im watching
To make code that loops... use a loop
bc with that code rn it works, but if the username is 3 letters or smaller i want it to continously ask for a bigger one
right
im tyrna make a method that loops
Methods don't loop
i want that if statement to call the method
Loops loop
You can call a method inside of a loop, sure
oh
well dam
so do i make a loop with that if statement?
String name;
Do
{
name = console.ReadLine();
}
While (name.Length <= 3)
Maybe this will work
angius
REPL Result: Success
Console Output
Compile: 636.571ms | Execution: 58.032ms | React with ❌ to remove this embed.
And, yeah, this would be the way
i dont understand that
where would i put that at?
Wherever you want to ask for the user's name
Do { something } then check condition, if true, keep doing things inside do {} until conditions is false
This is do loop does
ahhhh
okkk
just gotta figure that out know
i get it
ty
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.