一直提示:程序不包含适合于入口点的静态main方法。按照很多文章提供的解决方法都解决不了,比如把输出类型改成类库,反而带来了其他问题。求求大佬帮我看看怎么解决。代码如下:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class SqList
{
const int MaxSize = 100;
public string[] data;
public int[] frequency;
public int length;
public SqList()
{
data = new string[MaxSize];
frequency = new int[MaxSize];
length = 0;
}
public void CreateList(string[] split)
{
int i = 0;
int n = 0;
for (i = 0; i < split.Length; i++)
{
for (int m = 0; m < split.Length; m++)
{
if (split[m] != null)
{
data[i] = split[m];
length++;
frequency[i]++;
split[m] = null;
break;
}
else
{ continue; }
}
for (n = 1; n < split.Length; n++)
{
if (split[n] == null)
continue;
if (split[n] == data[i])
{
frequency[i]++;
split[n] = null;
}
else
{
continue;
}
}
}
}
public int ArticleNum()
{
return length;
}
public void GetAllFre(ref string[] data, ref int[] frequency)
{
for (int i = 0; data[i] != null; i++)
{
Console.WriteLine("字符={0},字频={1}", data[i], frequency[i]);
}
}
}
}
新建一个类库项目,代码拷贝过去
注意class前面加上public,否则没法调用
你的程序没有入口点,需要个Main函数,添加一个Main函数就好了,Static void Main(){ ... } 然后在Main函数里面调用你的Sqlist类。