Ronnie
Ronnie
CC#
Created by Ronnie on 4/14/2023 in #help
❔ Whats the difference between classes and public classes?
Tried looking at Microsoft docs earlier but the don't really answer the question. I already know what assess modifiers are, but how to do they affect classes?
37 replies
CC#
Created by Ronnie on 4/7/2023 in #help
✅ rock paper scissors game
// beginner project - rock, paper scissors game

using System;
using System.Collections.Generic;

namespace RockPaperScissors
{
class Program
{
static void Main(string[] args )
{
Console.WriteLine("Welcome to my rock paper scissors game!");

string[] choice = { "Rock", "Paper", "Scissors" };


int round = 0;

// counters here help to keep track of the amount of points the player and the computer have
int PointsUser = 0;
int PointsComp = 0;


while (round < 3) // best out of three
{
Random rand = new Random();
int index = rand.Next(choice.Length);

var CompChoice = choice[index];

Console.WriteLine("Choose your element: ");
string UserInput = Console.ReadLine();


if (UserInput == "Rock") && (CompChoice == "Paper")
{
Console.WriteLine("Round 1 goes to the user");
round++;
PointsUser++;
}
}

}
}
}
// beginner project - rock, paper scissors game

using System;
using System.Collections.Generic;

namespace RockPaperScissors
{
class Program
{
static void Main(string[] args )
{
Console.WriteLine("Welcome to my rock paper scissors game!");

string[] choice = { "Rock", "Paper", "Scissors" };


int round = 0;

// counters here help to keep track of the amount of points the player and the computer have
int PointsUser = 0;
int PointsComp = 0;


while (round < 3) // best out of three
{
Random rand = new Random();
int index = rand.Next(choice.Length);

var CompChoice = choice[index];

Console.WriteLine("Choose your element: ");
string UserInput = Console.ReadLine();


if (UserInput == "Rock") && (CompChoice == "Paper")
{
Console.WriteLine("Round 1 goes to the user");
round++;
PointsUser++;
}
}

}
}
}
I'm getting an error with the if statement, says that && is invalid
22 replies
CC#
Created by Ronnie on 3/24/2023 in #help
❔ ✅ C# lists
int[] arr = {1, 2, 3, 4, 5};
List<int> myList = new List<int>();
int[] arr = {1, 2, 3, 4, 5};
List<int> myList = new List<int>();
rather than using .Add() is there a way that i can put the array into myList in order to create the list from that
40 replies
CC#
Created by Ronnie on 3/24/2023 in #help
✅ multiple if statements
using System;
using System.Collections.Generic;


namespace CSharp
{
class Program
{

static void MyMethod(int var1, int var2, int var3)
{
if ((var1 > var2) && (var1 > var3)){
Console.WriteLine($"{var1} is the largest value");
}else if ((var2 > var1) && (var2 > var3)){
Console.WriteLine($"{var2} is the largest value");
}else if ((var3 > var1) && (var3 > var2)){
Console.WriteLine($"{var3} is the largest value");
}
}


static void Main(string[] args)
{
/*int[,] arr = { {1, 2, 3}, {4, 5, 6} };

for (int i = 0; i < arr.GetLength(0); i++){
for (int j = 0; j < arr.GetLength(1); j++){
Console.WriteLine(arr[i, j]);
}
}*/

MyMethod(5, 7, 9);
}
}
}
using System;
using System.Collections.Generic;


namespace CSharp
{
class Program
{

static void MyMethod(int var1, int var2, int var3)
{
if ((var1 > var2) && (var1 > var3)){
Console.WriteLine($"{var1} is the largest value");
}else if ((var2 > var1) && (var2 > var3)){
Console.WriteLine($"{var2} is the largest value");
}else if ((var3 > var1) && (var3 > var2)){
Console.WriteLine($"{var3} is the largest value");
}
}


static void Main(string[] args)
{
/*int[,] arr = { {1, 2, 3}, {4, 5, 6} };

for (int i = 0; i < arr.GetLength(0); i++){
for (int j = 0; j < arr.GetLength(1); j++){
Console.WriteLine(arr[i, j]);
}
}*/

MyMethod(5, 7, 9);
}
}
}
is there any way to make the MyMethod() function shorter?
11 replies
CC#
Created by Ronnie on 3/23/2023 in #help
✅ help with 2D arrays
using System;
using System.Collections.Generic;


namespace CSharp
{
class Program
{
static void Main(string[] args)
{

int[,] arr = { {1, 2, 3}, {4, 5, 6} };

foreach (int i in arr){
Console.WriteLine(arr[i]);
}
}
}
}
using System;
using System.Collections.Generic;


namespace CSharp
{
class Program
{
static void Main(string[] args)
{

int[,] arr = { {1, 2, 3}, {4, 5, 6} };

foreach (int i in arr){
Console.WriteLine(arr[i]);
}
}
}
}
How would i loop thorugh a 2d array and print their values instead of their index? this is hat i have so far
11 replies
CC#
Created by Ronnie on 3/18/2023 in #help
✅ User input
41 replies
CC#
Created by Ronnie on 3/18/2023 in #help
❔ ✅ Error -> scriptcs : The term 'scriptcs' is not recognized as the name of a cmdlet, function...
using System;

namespace CSharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}
using System;

namespace CSharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}
Getting this error: scriptcs : The term 'scriptcs' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
54 replies