我在行中收到以下错误_dict.Add(id, ar):
你调用的对象是空的
这是我的代码:
public Dictionary<int, byte[]> _dict;
public IDictionary<int, byte[]> dict()
{
string sp = HttpContext.Current.Server.MapPath("Images");
DirectoryInfo folder = new DirectoryInfo(sp);
FileInfo[] files = folder.GetFiles("*.jpg");
foreach (var file in files)
{
string name = file.Name;
int id = Convert.ToInt32(name.Substring(0, name.Length - 4));
FileStream fS = new FileStream(sp + "\\" + name, FileMode.Open, FileAccess.Read);
byte[] ar = new byte[fS.Length];
fS.Read(ar, 0, (int)fS.Length);
fS.Close();
_dict.Add(id, ar);
}
return _dict;
}
Run Code Online (Sandbox Code Playgroud) 我怎样才能从字符串中分割数据?
我有这样的字符串,
Url=http://www.yahoo.com UrlImage=http://l.yimg.com/a/i/ww/met/yahoo_logo_in_061509.png UrlTitle=Yahoo! India UrlDescription=Welcome to Yahoo!, the world's most visited home page. Quickly find what you're searching for, get in touch with friends and stay in-the-know with the latest news and information.
Run Code Online (Sandbox Code Playgroud)
我想要将这些信息拆分为
http://www.yahoo.com
http://l.yimg.com/a/i/ww/met/yahoo_logo_in_061509.png
Yahoo! India
Welcome to Yahoo!, the world's most visited home page. Quickly find what you're searching for, get in touch with friends and stay in-the-know with the latest news and information.
Run Code Online (Sandbox Code Playgroud)
如何将上面的字符串分成这四个部分并保存到每个部分的临时变量中?
string url = http://www.yahoo.com
string urlImage = http://l.yimg.com/a/i/ww/met/yahoo_logo_in_061509.png
string urlTitle …
我需要在数组A中找到数组B中不存在的值
A = {1,2,3,4,5,6,7,8,9,10}
B = {1,2,3,7,8}
result = {4,5,6,9,10}
Run Code Online (Sandbox Code Playgroud)
任何人都可以给我任何指示吗?
对不起我的英语不好提前.我正在为大学的一个项目制作一个游戏并且卡在这个部分,我必须在一个集合中保存每个游戏的所有玩家名字.所以我得到了这两个课程
class Score
{
...
}
class ScoreList
{
public List<Score> NamesList = new List<Score>();
public ScoreList()
{}
public void addScorePlayers(string nom1, string nom2)
{
Score part = new Score(player1, player2);
NamesList.Add(part);
}
}
Run Code Online (Sandbox Code Playgroud)
然后我在表单中创建一个对象
public partial class FormCreateScoreList : Form
{
public static ScoreList Names = new ScoreList();
.....
.....
}
Run Code Online (Sandbox Code Playgroud)
然后在另一种形式中,我将两个玩家的名字添加到ScoreList中
public partial class FormCreateScoreScreen : Form
{
FormCreateScoreList.obj.addScorePlayers("Player1","Player2")
}
Run Code Online (Sandbox Code Playgroud)
但是当我调试时,错误就出现了
"Inconsistent accessibility: parameter type 'FinalProject.ScoreList' is less accessible than method 'FinalProject.FormCreateScoreList.Names'"
Run Code Online (Sandbox Code Playgroud)
请帮助,我不知道如何使用我在另一个表单上创建的对象中的方法