Cheetah
Cheetah
CC#
Created by Cheetah on 9/29/2023 in #help
✅ I have 5 errors and have 0 ideas on how to fix them :(
Ok so i havve syntax error, '(' expected at line 31 i havev ) expected at line 31 i havve ; expected at line 31 i have cannot implicitly convertt type 'Char' to 'string' on line 29 and cannot implicitly convert type 'string' to 'bool'
using static System.Net.Mime.MediaTypeNames;

namespace Hangman
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("This is a game of hangman, have fun");
List<string> list = new List<string>();
list.Add("Apples");
list.Add("Bees");
list.Add("constable");
string itemone = list[0];
string itemtwo = list[1];
string itemthree = list[2];
string allitems = itemone + itemtwo + itemthree;
Console.WriteLine(allitems);
Random random = new Random();
int randomitem = random.Next(0, 2);




if (randomitem == 0)
{
for (int i = 0; i < itemone.Length; i++)
{
string letter = itemone[i];
string userinput = Console.ReadLine();
if userinput = letter { Console.WriteLine(letter, "_____")};
Console.WriteLine(letter);

};
}


else if (randomitem == 1)
{
for (int i = 0; i < itemtwo.Length; i++)
{
char letter = itemone[i];
Console.WriteLine(letter);
};
}

else if (randomitem == 2)
{
for (int i = 0; i < itemthree.Length; i++)
{
char letter = itemone[i];
Console.WriteLine(letter);
}


}
}
}
}
using static System.Net.Mime.MediaTypeNames;

namespace Hangman
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("This is a game of hangman, have fun");
List<string> list = new List<string>();
list.Add("Apples");
list.Add("Bees");
list.Add("constable");
string itemone = list[0];
string itemtwo = list[1];
string itemthree = list[2];
string allitems = itemone + itemtwo + itemthree;
Console.WriteLine(allitems);
Random random = new Random();
int randomitem = random.Next(0, 2);




if (randomitem == 0)
{
for (int i = 0; i < itemone.Length; i++)
{
string letter = itemone[i];
string userinput = Console.ReadLine();
if userinput = letter { Console.WriteLine(letter, "_____")};
Console.WriteLine(letter);

};
}


else if (randomitem == 1)
{
for (int i = 0; i < itemtwo.Length; i++)
{
char letter = itemone[i];
Console.WriteLine(letter);
};
}

else if (randomitem == 2)
{
for (int i = 0; i < itemthree.Length; i++)
{
char letter = itemone[i];
Console.WriteLine(letter);
}


}
}
}
}
55 replies
CC#
Created by Cheetah on 8/11/2023 in #help
❔ How do i make user input text appear
public IActionResult ToDo(string Input)
{

Input = ViewBag.UserInput;
ViewBag.UserInput = Input;
return View();
}
public IActionResult ToDo(string Input)
{

Input = ViewBag.UserInput;
ViewBag.UserInput = Input;
return View();
}
@page
@model Webthing.Views.Home.To_doModel

<h1>This is your To Do page</h1>



<form method="post" asp-action="ToDo">
<input type="text" name="Input" /> <!-- Change name to "input" -->
</form>

<center><p>@ViewBag.UserInput</p></center>
@page
@model Webthing.Views.Home.To_doModel

<h1>This is your To Do page</h1>



<form method="post" asp-action="ToDo">
<input type="text" name="Input" /> <!-- Change name to "input" -->
</form>

<center><p>@ViewBag.UserInput</p></center>
this is part of my code rrelating to this so like how do i make UserInput appear on the website? im using cshtml
6 replies
CC#
Created by Cheetah on 8/7/2023 in #help
How to make If statement in loop only run once
i have three if statements and when i write a number it runs infinitetly even tho its if
using System;
using System.Runtime.InteropServices;

namespace Guessing_game
{
internal class Program
{
static void Main(string[] args)
{
Random rnd = new Random();
int num = rnd.Next(1, 100);
Console.WriteLine(num);
Console.WriteLine("Guess the number");
string Guess = Console.ReadLine();

int IntGuess = int.Parse(Guess);

Console.WriteLine(IntGuess);

int on = 0;

while (on < 1)
{
if (num > IntGuess)
{
Console.WriteLine("Higher");
}

if (num < IntGuess)
{
Console.WriteLine("Lower");
}

if (num == IntGuess)
{
Console.WriteLine("Good job");

}
}
}
}
}
using System;
using System.Runtime.InteropServices;

namespace Guessing_game
{
internal class Program
{
static void Main(string[] args)
{
Random rnd = new Random();
int num = rnd.Next(1, 100);
Console.WriteLine(num);
Console.WriteLine("Guess the number");
string Guess = Console.ReadLine();

int IntGuess = int.Parse(Guess);

Console.WriteLine(IntGuess);

int on = 0;

while (on < 1)
{
if (num > IntGuess)
{
Console.WriteLine("Higher");
}

if (num < IntGuess)
{
Console.WriteLine("Lower");
}

if (num == IntGuess)
{
Console.WriteLine("Good job");

}
}
}
}
}
36 replies
CC#
Created by Cheetah on 8/7/2023 in #help
How to make string to int
pls help me i needa make a string variable to int variable for my code but i cant figure out how heres my code
using System;
using System.Runtime.InteropServices;

namespace Guessing_game
{
internal class Program
{
static void Main(string[] args)
{
Random rnd = new Random();
int num = rnd.Next();
Console.WriteLine(num);
Console.WriteLine("Guess the number");
Console.ReadLine();
string Guess = Console.ReadLine();

int IntGuess = int.Parse(Guess);

Console.WriteLine(IntGuess);
if (num == IntGuess)
{
Console.WriteLine("Good job");
}
}
}
}
using System;
using System.Runtime.InteropServices;

namespace Guessing_game
{
internal class Program
{
static void Main(string[] args)
{
Random rnd = new Random();
int num = rnd.Next();
Console.WriteLine(num);
Console.WriteLine("Guess the number");
Console.ReadLine();
string Guess = Console.ReadLine();

int IntGuess = int.Parse(Guess);

Console.WriteLine(IntGuess);
if (num == IntGuess)
{
Console.WriteLine("Good job");
}
}
}
}
45 replies
CC#
Created by Cheetah on 8/6/2023 in #help
Ok so i DID NOT add hello world to my code but it still appears
48 replies
CC#
Created by Cheetah on 8/6/2023 in #help
"name space 'helloworld2' already contains a definition for a 'program'
Man this my first code ever in c# it worked two seconds ago and now it dont what do i do pls heres the code " using System; namespace Helloworld2 { internal class Program { static void Main(string[] args) { int Number =0; Console.WriteLine("Hello world"); Console.Beep(); while (Number > 10) {Console.Beep(); Number++; Console.WriteLine("Beep");
} } } } " i have two error one that was the starting text thing and the otther is "type 'program' already defines a member called 'Main' with the same parameter types
23 replies