我已经查看了其他问题,但我无法理解答案中的内容,因此我会在此处发布我的代码:
public class Program
{
public static void Main()
{
Program startUp = new Program();
Console.Clear();
string file = @FILEPATH
string grades = File.ReadAllText(file);
int acount = grades.Count(c => c == 'A');
startUp.Grapher();
}
public class Graph
{
public static string Grapher(int acount)
{
Console.WriteLine(String.Concat(Enumerable.Repeat("*", acount))); Console.Write(": A");
}}
任何帮助或解释都会很棒!
答案 0 :(得分:3)
好的,从我看到你创建一个Program
类实例,然后尝试使用Graph
类方法。
你应该使用Graph
类实例。
public static void Main()
{
Console.Clear();
string file = @FILEPATH
string grades = File.ReadAllText(file);
int acount = grades.Count(c => c == 'A');
Graph.Grapher(acount);// this is the change
}
,Graph类将是:
public class Graph
{
public static void Grapher(int acount)// the change is here
{
Console.WriteLine(String.Concat(Enumerable.Repeat("*", acount))); Console.Write(": A");
}
}