C
C#8mo ago
js

✅ cant assign a value to a variable

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using JustNom.Menu;
using JustNom.OrdersFolder;

namespace JustNom.Menu
{
internal abstract class FoodMenu
{
public static int selectedNum;

public static int numberOfLines;
public abstract string TakeawayName();
public abstract List<string> Toppings();
public abstract List<string> Garnishes();
public abstract List<string> LoadedBurgers();
public abstract List<string> LoadedPizzas();
public static void LoadFoodMenu()
{
Console.WriteLine("");
Console.WriteLine("JustNom Order Manager");
Console.WriteLine("");
Console.WriteLine("Please select a menu to load.");
Console.WriteLine("");

string[] filePaths = Directory.GetFiles(@"C:\Users\Joe\Documents\Uni\Programming Portfolio\JustNom\JustNom\TestData", "*.nom");

int count1 = 1;

foreach (string file in filePaths)
{
Console.WriteLine($"{count1}. {Path.GetFileName(file)}");
count1 = count1 + 1;
}

selectedNum = ConsoleHelpers.GetIntegerInRange(1, count1, "Please select a valid menu");

string[] selectedFile = File.ReadLines(filePaths[selectedNum - 1]).ToArray();

StreamReader reader = new StreamReader(filePaths[selectedNum - 1]);

numberOfLines = 0;
while (!reader.EndOfStream)
{
reader.ReadLine();
numberOfLines++;
}

reader.BaseStream.Seek(0, SeekOrigin.Begin);

TakeawayName = selectedFile[0];

Console.WriteLine($"{selectedFile[2]}");
}

}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using JustNom.Menu;
using JustNom.OrdersFolder;

namespace JustNom.Menu
{
internal abstract class FoodMenu
{
public static int selectedNum;

public static int numberOfLines;
public abstract string TakeawayName();
public abstract List<string> Toppings();
public abstract List<string> Garnishes();
public abstract List<string> LoadedBurgers();
public abstract List<string> LoadedPizzas();
public static void LoadFoodMenu()
{
Console.WriteLine("");
Console.WriteLine("JustNom Order Manager");
Console.WriteLine("");
Console.WriteLine("Please select a menu to load.");
Console.WriteLine("");

string[] filePaths = Directory.GetFiles(@"C:\Users\Joe\Documents\Uni\Programming Portfolio\JustNom\JustNom\TestData", "*.nom");

int count1 = 1;

foreach (string file in filePaths)
{
Console.WriteLine($"{count1}. {Path.GetFileName(file)}");
count1 = count1 + 1;
}

selectedNum = ConsoleHelpers.GetIntegerInRange(1, count1, "Please select a valid menu");

string[] selectedFile = File.ReadLines(filePaths[selectedNum - 1]).ToArray();

StreamReader reader = new StreamReader(filePaths[selectedNum - 1]);

numberOfLines = 0;
while (!reader.EndOfStream)
{
reader.ReadLine();
numberOfLines++;
}

reader.BaseStream.Seek(0, SeekOrigin.Begin);

TakeawayName = selectedFile[0];

Console.WriteLine($"{selectedFile[2]}");
}

}
}
9 Replies
js
jsOP8mo ago
second to last line I try to assign the takeaway name to the takeawayname variable i declared at the start of the code but im getting an error saying cannot assign because it is a method group, i need this variable to be accessible for other c# classes in my program.
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
js
jsOP8mo ago
is it the abstract bit i dont really understand it
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
js
jsOP8mo ago
oh
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
js
jsOP8mo ago
lmfao im stupid
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
js
jsOP8mo ago
ty bro#
Want results from more Discord servers?
Add your server